-
Notifications
You must be signed in to change notification settings - Fork 8
/
Player.py
51 lines (39 loc) · 1.44 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
__author__ = 'oddBit'
from kivy.uix.image import Image
from random import choice
from data.gameData import *
class Player(Image):
def __init__(self, stars, **kwargs):
super(Player, self).__init__(**kwargs)
self.state = PlayerStates.SIT_LEFT
self.source = player_sprites[self.state]
self.stars = stars
self.anim_delay = 0.2
def select_player(self):
if self.state == PlayerStates.SIT_LEFT:
self.state = PlayerStates.SIT_LEFT_SELECTED
else:
self.state = PlayerStates.SIT_RIGHT_SELECTED
self.source = player_sprites[self.state]
def stop_player(self):
self.state = choice([PlayerStates.SIT_LEFT, PlayerStates.SIT_RIGHT])
self.source = player_sprites[self.state]
def move_left(self):
self.state = PlayerStates.WALK_LEFT
self.source = player_sprites[self.state]
def move_right(self):
self.state = PlayerStates.WALK_RIGHT
self.source = player_sprites[self.state]
def jump_left(self):
self.state = PlayerStates.JUMP_LEFT
self.source = player_sprites[self.state]
def jump_right(self):
self.state = PlayerStates.JUMP_RIGHT
self.source = player_sprites[self.state]
def player_dead(self):
self.state = PlayerStates.DEAD
self.source = player_sprites[self.state]
def add_star(self):
self.stars += 1
def use_star(self):
self.stars -= 1