This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_moving_hero.py
55 lines (46 loc) · 1.59 KB
/
w_moving_hero.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
52
53
54
55
from i_moving_char import FiringCharacter
from panda3d.core import TransparencyAttrib
import random
import z_m
import math
class PlayerCharacter(FiringCharacter):
def __init__(self, startPos, stage, heroHP, actorName, map_boundaries):
FiringCharacter.__init__(
self, 0, map_boundaries)
self.actorName = actorName
self.hp = heroHP
self.indexNumber = 0 # if multiplayer, this will need to be passed on creation
self.stage = stage
self.startPos = startPos
self.name = 'hero'
self.speed= 9
self.collision_size = (0, 0, 0.2, 1.0)
self.initActor()
def initActor(self):
self.loadActor(self.startPos)
self.actor.setTransparency(TransparencyAttrib.MAlpha)
self.actor.setAlphaScale(1.0)
self.initCollision()
self.direction = None
def flash(self):
base.messenger.send(z_m.PLAYER_HURT)
self.can_hurt = False
taskMgr.add(self.flashing_colour, 'hero_flash')
def flashing_colour(self, task):
if task.time < 1.0:
self.actor.setAlphaScale(task.time % 1.0)
return task.cont
self.actor.setAlphaScale(1.0)
self.can_hurt = True
return task.done
def kill(self):
self.direction = None
self.can_fire = False
self.actor.setPos(self.indexNumber-15, self.indexNumber-15, 100)
base.messenger.send(z_m.PLAYER_HURT)
def updatePos(self, dt):
self.updatePosActor(dt)
def fire(self):
self.can_fire = False
def reset_fire(self):
self.can_fire = True