Added cooldown to pinmiks
This commit is contained in:
parent
f3ccc88196
commit
5066d84f8d
18
gamedata/objects/fullscreenbutton.py
Normal file
18
gamedata/objects/fullscreenbutton.py
Normal file
@ -0,0 +1,18 @@
|
||||
from gamedata.objects.button import Button
|
||||
|
||||
class FullScreen(Button):
|
||||
|
||||
def __init__(self,x,y,game,w,h):
|
||||
|
||||
super().__init__(x,y,game,w,h)
|
||||
|
||||
self.text = "Toggle Fullscreen"
|
||||
|
||||
def toggle(self,game):
|
||||
game.globals["fullscreen"] = not game.globals["fullscreen"]
|
||||
if game.globals["fullscreen"]:
|
||||
game.screen = game.pygame.display.set_mode((game.screen.get_width(),game.screen.get_height()),game.pygame.FULLSCREEN)
|
||||
else:
|
||||
game.screen = game.pygame.display.set_mode((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT),game.pygame.RESIZABLE)
|
||||
|
||||
self.click = toggle
|
@ -13,6 +13,9 @@ class Lemming(BaseObject):
|
||||
self.normalspeed = self.basespeed # Speed "objective"
|
||||
self.speed = 0 # Current speed, leaning towards objective speed
|
||||
|
||||
self.cooldown = False
|
||||
self.cooldowntimer = game.lib.Timer(0.5)
|
||||
|
||||
self.handlepause = True
|
||||
|
||||
self.scoreratio = 0.3
|
||||
@ -57,6 +60,11 @@ class Lemming(BaseObject):
|
||||
# Depth updating based on position
|
||||
self.depth = 1+self.rect[1]/100
|
||||
|
||||
# Cooldown to be relaunched
|
||||
if self.cooldown:
|
||||
if self.cooldowntimer.tick(self.game.dt):
|
||||
self.cooldown = False
|
||||
|
||||
# Lean towards the normal speed
|
||||
if self.selected:
|
||||
self.normalspeed = 0
|
||||
@ -99,12 +107,13 @@ class Lemming(BaseObject):
|
||||
# Releasing it
|
||||
if mouse["click"]==0 or not self.holdrect.collidepoint(mouse["campos"]):
|
||||
self.launch()
|
||||
self.cooldown = True
|
||||
else:
|
||||
if self.holdtimer.tick(self.game.dt):
|
||||
self.selected = False
|
||||
self.holdtimer.reset()
|
||||
self.normalspeed = self.basespeed
|
||||
if self.game.inputs["mouse"]["click"]==1:
|
||||
if self.game.inputs["mouse"]["click"]==1 and not self.cooldown:
|
||||
if self.rect.collidepoint(mouse["campos"]):
|
||||
self.selected = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user