1 require
"scripts/TinyPhazon"
7 Player
.image_l
, Player
.w
, Player
.h
= get_image("images/player_left.png")
8 Player
.image_r
= get_image("images/player_right.png")
9 Player
.image_c
= get_image("images/player_charged.png")
15 Player
.psys
= ParticleSystem
:new()
16 Player
.psys
.object
= TinyPhazon
17 Player
.psys
.angle_min
= 45
18 Player
.psys
.angle_max
= 135
19 Player
.psys
.speed_min
= 4
20 Player
.psys
.speed_max
= 7
21 Player
.psys
.particles_per_update_min
= 5
22 Player
.psys
.particles_per_update_max
= 10
23 Player
.psys
.life_min
= 1
24 Player
.psys
.life_max
= 5
25 Player
.psys
.on
= false
27 function Player
:new(o
)
31 o
.lerp
= create_absolute_lerp(20,20,8)
36 function Player
:update(delta
)
37 if self
.right
== true and self
.left
== true then
39 elseif self
.right
== true then
41 elseif self
.left
== true then
47 Object
.update(self
, delta
)
49 if self
.x
< 0 then self
.x
= 0 end
50 if self
.x
> 640 - 32 then self
.x
= 640 - 32 end
52 if self
.charges
< 20 then
58 self
.psys
.x
= self
.x
+ 8
65 function Player
:shoot()
66 if self
.charges
>= 20 then
67 bullet_list
:push_back(PhazonBlast
:new({x
=self
.x
, y
=self
.y
, heading
=90, speed
=10}))
68 self
.charges
= self
.charges
- 20
73 function Player
:draw()
75 if self
.charges
< 20 then
76 local dist
= self
.lerp(self
.charges
)
78 display(self
.image_l
, self
.x
-self
.x_offset
-dist
, self
.y
-self
.y_offset
, self
.rotation
, 1, 1, 255)
79 display(self
.image_r
, self
.x
-self
.x_offset
+dist
, self
.y
-self
.y_offset
, self
.rotation
, 1, 1, 255)
81 display(self
.image_c
, self
.x
-self
.x_offset
, self
.y
-self
.y_offset
, self
.rotation
, 1, 1, 255)