-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.py
29 lines (23 loc) · 939 Bytes
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import arcade
from constants import PLAYER_JUMP_SPEED
class Player(arcade.Sprite):
ANGLE_CHANGE = 5 # has to be divisor of 90
def __init__(self, image="assets/images/player.png", jump_sound="assets/sounds/jump.wav"):
super().__init__(image)
self.jump_sound = arcade.load_sound(jump_sound)
def jump(self, *, big_jump=False):
"""
Make the player jump and handles his rotation.
:param big_jump: bool, if true the jump will be 1.6 times more powerful (useful for jump-pads)
"""
if big_jump:
self.change_y = PLAYER_JUMP_SPEED * 1.6
else:
self.change_y = PLAYER_JUMP_SPEED
self.angle -= self.ANGLE_CHANGE # to kick-start update
self.change_angle = - self.ANGLE_CHANGE
arcade.play_sound(self.jump_sound)
def draw(self):
super().draw()
if self.angle % 90 == 0:
self.change_angle = 0