From 86c9a5fd0d84a5fbd5e98aed1cd7878aeb9e8066 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Fri, 17 Sep 2021 07:43:53 +0200 Subject: [PATCH] Updated sliders --- gamedata/objects/ingame/manager.py | 1 - gamedata/objects/sliders/slider.py | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gamedata/objects/ingame/manager.py b/gamedata/objects/ingame/manager.py index fe59c08..a517818 100644 --- a/gamedata/objects/ingame/manager.py +++ b/gamedata/objects/ingame/manager.py @@ -53,7 +53,6 @@ class Manager(BaseObject): # Game over if self.endtimer.tick(self.game.dt): self.game.globals["score"] = self.score - print(self.game.globals["score"]) self.game.scenes.gameover(self.game) if self.invincible: diff --git a/gamedata/objects/sliders/slider.py b/gamedata/objects/sliders/slider.py index 3adfcf6..bfefb3b 100644 --- a/gamedata/objects/sliders/slider.py +++ b/gamedata/objects/sliders/slider.py @@ -50,15 +50,14 @@ class Slider(base.BaseObject): def step(self): game = self.game - if self.rect[0]<=game.inputs["mouse"]["pos"][0]+game.globals["camerax"]<=self.rect[0]+self.rect[2]: - if self.rect[1]<=game.inputs["mouse"]["pos"][1]+game.globals["cameray"]<=self.rect[1]+self.rect[3]: - if game.inputs["mouse"]["click"]>1: - self.rect[0] = game.inputs["mouse"]["pos"][0]+game.globals["camerax"]-self.rect[3]/2 - self.rect[0] = min(self.rect[0],self.baserect[0]+self.maxwidth) - self.rect[0] = max(self.rect[0],self.baserect[0]) - self.dragged = True + if self.baserect.collidepoint(game.inputs["mouse"]["pos"]): + if game.inputs["mouse"]["click"]>1: + self.rect[0] = game.inputs["mouse"]["pos"][0]-self.rect[3]/2 + self.rect[0] = min(self.rect[0],self.baserect[0]+self.maxwidth) + self.rect[0] = max(self.rect[0],self.baserect[0]) + self.dragged = True - self.postovalue() + self.postovalue() if self.dragged and game.inputs["mouse"]["click"]==0: # Le slider a été laché