def move(self): if Input.check(Key.RIGHT): self.x += self.speed * PP.elapsed if Input.check(Key.LEFT): self.x -= self.speed * PP.elapsed if Input.check(Key.DOWN): self.y += self.speed * PP.elapsed if Input.check(Key.UP): self.y -= self.speed * PP.elapsed
def update(self): if not self.world: return if self.collide_point(self.x - self.world.camera.x, self.y - self.world.camera.y, Input.mouse_x, Input.mouse_y): if Input.mouse_released() and self._callback: self._callback(*self._args, **self._kwargs) elif Input.mouse_down(): self._map.play('down') else: self._map.play('over') else: self._map.play('up')
def update(self): self._time_interval += PP.elapsed if self._time_interval >= 3: self.graphic.play('Blinking') if Input.check('LEFT'): self.x -= 50 * PP.elapsed if Input.check('RIGHT'): self.x += 50 * PP.elapsed if Input.check('UP'): self.y -= 50 * PP.elapsed if Input.check('DOWN'): self.y += 50 * PP.elapsed
def update(self): # Update the score text to reflect the current score self.score_text.text = str(self.score) # Restart the game if they died and press enter. if self._game_over and Input.check(Key.RETURN): PP.world = GameRoom()
def __init__(self): Entity.__init__(self) self._time_interval = 0 self.graphic = Spritemap('EntitySheet.png', 40, 20, self.on_animation_end) self.graphic.add('Stopped', [0]) self.graphic.add('Blinking', list(range(10)), 24) Input.define('UP', Key.W, Key.UP) Input.define('DOWN', Key.S, Key.DOWN) Input.define('LEFT', Key.A, Key.LEFT) Input.define('RIGHT', Key.D, Key.RIGHT) self.type = 'GameEntity' self.graphic.play('Blinking')
def shoot(self): if Input.pressed(Key.SPACE): self.world.add(Bullet(self.x + 36, self.y + 12)) self.bullet_shoot.play()