]>
Commit | Line | Data |
---|---|---|
10a0e290 BB |
1 | --parameters |
2 | this.actorname = "Bullet: Crawlshot" | |
3 | this.enemy = enemy_weapon | |
4 | this.speed = 6 | |
5 | this.controllable = false | |
6 | this.physics = true | |
7 | this.bumpcount = 0 | |
8 | this.bumplimit = 4 | |
9 | ||
10 | print(">>> Entity Created - "..this.actorname); | |
11 | ||
12 | function this.move(this) | |
13 | ||
14 | if(this:get_currentdirection() == right) then | |
15 | this:set_ownspeed(this.speed) | |
16 | end | |
17 | ||
18 | if (this:get_currentdirection() == left) then | |
19 | this:set_ownspeed(-this.speed) | |
20 | end | |
21 | ||
22 | if ( ( not this:can_move(left, this:get_x(), this:get_y()) and this:get_currentdirection() == left ) or | |
23 | ( not this:can_move(right, this:get_x(), this:get_y()) and this:get_currentdirection() == right ) ) then | |
24 | this.bumpcount = this.bumpcount + 1 | |
25 | ||
26 | this:switchdirection() | |
27 | if this.bumpcount >= this.bumplimit then | |
28 | this:set_dying(true) | |
29 | end | |
30 | end | |
31 | end | |
32 | ||
33 | function this.switchdirection(this) | |
34 | ||
35 | if(this:get_currentdirection() == right) then | |
36 | this:set_currentdirection(left) | |
37 | this:set_ownspeed(-this.speed) | |
38 | elseif (this:get_currentdirection() == left) then | |
39 | this:set_currentdirection(right) | |
40 | this:set_ownspeed(this.speed) | |
41 | end | |
42 | end | |
43 | ||
44 | function this.act(this) | |
45 | this:move() | |
46 | end | |
47 | ||
48 | --END |