-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
41 lines (36 loc) · 1.08 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
import arcade
from data import *
class player(arcade.Sprite):
def __init__(self,filename,center_x,center_y,isDrunk=False):
super().__init__(filename,SPRITE_SCALING_PLAYER)
self.center_x=center_x
self.center_y=center_y
self.BAC = 0 if isDrunk == False else DRUNK_LEVEL_PLAYER
self.isDrunk = isDrunk
self.isSuperDrunk = False
self.can_move= True
self.static_time=0
self.invincible= False
self.invincible_time=None
self.username="Bd"
def update(self, delta_time):
# Decrease the static_time attribute by delta time.
if self.can_move == False:
if self.static_time <= 0:
self.can_move=True
self.static_time = 0
else :
self.change_x = 0
self.change_y = 0
self.static_time -= delta_time
# Handle isSuperDrunk
if self.BAC >= SUPER_DRUNK_LEVEL_PLAYER:
if self.isSuperDrunk == False: self.isSuperDrunk = True
else:
self.isSuperDrunk = False
# Decrease the invincible_time attribute by delta time.
if self.invincible == True:
if self.invincible_time <= 0:
self.invincible=False
else :
self.invincible_time -= delta_time