]> git.r.bdr.sh - rbdr/pico-engine/blame - scripts/shot-crawl.lua
first commit
[rbdr/pico-engine] / scripts / shot-crawl.lua
CommitLineData
10a0e290
BB
1--parameters
2this.actorname = "Bullet: Crawlshot"
3this.enemy = enemy_weapon
4this.speed = 6
5this.controllable = false
6this.physics = true
7this.bumpcount = 0
8this.bumplimit = 4
9
10print(">>> Entity Created - "..this.actorname);
11
12function 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
31end
32
33function 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
42end
43
44function this.act(this)
45 this:move()
46end
47
48--END