#11 Added rumble effect when eating pills. /JL
This commit is contained in:
14
pman.py
14
pman.py
@@ -7,11 +7,12 @@ from actors.ghost_mode_controller import GhostModeController
|
|||||||
from hud import HUD
|
from hud import HUD
|
||||||
from maze import Maze
|
from maze import Maze
|
||||||
|
|
||||||
__version__ = "0.5.0"
|
__version__ = "0.5.1"
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
|
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
|
||||||
HAT_REPEAT_INTERVAL = 200 # milliseconds between repeats
|
HAT_REPEAT_INTERVAL = 200 # milliseconds between repeats
|
||||||
|
RUMBLE_TIMEOUT = 200
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -49,6 +50,7 @@ class Game:
|
|||||||
self.ghost_home_center = (self.screen_width // 2, (self.screen_height) // 2)
|
self.ghost_home_center = (self.screen_width // 2, (self.screen_height) // 2)
|
||||||
self.ghosts = self.spawn_ghosts(self.ghost_home_center)
|
self.ghosts = self.spawn_ghosts(self.ghost_home_center)
|
||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
|
self.rumble_timer = pygame.time.get_ticks()
|
||||||
|
|
||||||
def spawn_ghosts(self, center_position):
|
def spawn_ghosts(self, center_position):
|
||||||
"""
|
"""
|
||||||
@@ -89,6 +91,10 @@ class Game:
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
def main_loop(self):
|
def main_loop(self):
|
||||||
|
if self.joysticks:
|
||||||
|
if pygame.time.get_ticks() - self.rumble_timer > RUMBLE_TIMEOUT:
|
||||||
|
self.joysticks[self.joy.get_instance_id()].controllers[0].stop_rumble()
|
||||||
|
|
||||||
self.screen.fill(Colors.Black.value)
|
self.screen.fill(Colors.Black.value)
|
||||||
|
|
||||||
self.handle_events()
|
self.handle_events()
|
||||||
@@ -229,8 +235,14 @@ class Game:
|
|||||||
match self.maze.collect_dot(self.player.location[0], self.player.location[1]):
|
match self.maze.collect_dot(self.player.location[0], self.player.location[1]):
|
||||||
case "dot":
|
case "dot":
|
||||||
self.hud.add_points(10)
|
self.hud.add_points(10)
|
||||||
|
if self.joysticks:
|
||||||
|
self.joysticks[self.joy.get_instance_id()].controllers[0].rumble(25, 50)
|
||||||
|
self.rumble_timer = pygame.time.get_ticks()
|
||||||
case "power":
|
case "power":
|
||||||
self.hud.add_points(50)
|
self.hud.add_points(50)
|
||||||
|
if self.joysticks:
|
||||||
|
self.joysticks[self.joy.get_instance_id()].controllers[0].rumble(255, 255)
|
||||||
|
self.rumble_timer = pygame.time.get_ticks()
|
||||||
self.ghost_mode_controller.trigger_frightened()
|
self.ghost_mode_controller.trigger_frightened()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user