blob: 01b43dc8986048e6592b15623af9e167f53b9579 (
plain)
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
|
--parameters
this.actorname = "Bullet: Crawlshot"
this.enemy = enemy_weapon
this.speed = 6
this.controllable = false
this.physics = true
this.bumpcount = 0
this.bumplimit = 4
print(">>> Entity Created - "..this.actorname);
function this.move(this)
if(this:get_currentdirection() == right) then
this:set_ownspeed(this.speed)
end
if (this:get_currentdirection() == left) then
this:set_ownspeed(-this.speed)
end
if ( ( not this:can_move(left, this:get_x(), this:get_y()) and this:get_currentdirection() == left ) or
( not this:can_move(right, this:get_x(), this:get_y()) and this:get_currentdirection() == right ) ) then
this.bumpcount = this.bumpcount + 1
this:switchdirection()
if this.bumpcount >= this.bumplimit then
this:set_dying(true)
end
end
end
function this.switchdirection(this)
if(this:get_currentdirection() == right) then
this:set_currentdirection(left)
this:set_ownspeed(-this.speed)
elseif (this:get_currentdirection() == left) then
this:set_currentdirection(right)
this:set_ownspeed(this.speed)
end
end
function this.act(this)
this:move()
end
--END
|