]> git.r.bdr.sh - rbdr/pico-engine/blob - build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua
Update project so it compiles
[rbdr/pico-engine] / build / Debug / Pico-Lua-Test.app / Contents / Resources / npc_walker.lua
1 --Configuration for the Jumper
2 this.actorname = "Enemy: Walker"
3
4 --the directions
5 up=0
6 right=1
7 down=2
8 left = 3
9
10 --parameters
11 this.enemy = 1
12 this.controllable = 0
13 this.speed = 2
14
15 print(">>> Entity Created - "..this.actorname);
16
17 function this.walk(this)
18 if(this:get_currentdirection() == left) then
19 if ( this:can_move(left, this:get_x(), this:get_y()) and
20 not this:can_move(down, this:get_x()+this:get_ownspeed(), this:get_y())) then
21 if this:get_collision(left) then
22 this:set_currentdirection(right)
23 else
24 this:set_ownspeed(-this.speed)
25 end
26 this:set_oldclip(1)
27 else
28 this:set_currentdirection(right)
29 this:set_ownspeed(this.speed)
30 end
31 end
32
33 if(this:get_currentdirection() == right) then
34 if ( this:can_move(right, this:get_x(), this:get_y()) and
35 not this:can_move(down, this:get_x()+this:get_ownspeed(), this:get_y())) then
36 if this:get_collision(right) then
37 this:set_currentdirection(left)
38 else
39 this:set_ownspeed(this.speed)
40 end
41 this:set_oldclip(2)
42 else
43 this:set_currentdirection(left)
44 this:set_ownspeed(-this.speed)
45 end
46 end
47 end
48
49 function this.act(this)
50 this:walk()
51 end
52
53 --END