]> git.r.bdr.sh - rbdr/pico-engine/blame - 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
CommitLineData
10a0e290
BB
1--Configuration for the Jumper
2this.actorname = "Enemy: Walker"
3
4--the directions
5up=0
6right=1
7down=2
8left = 3
9
10--parameters
11this.enemy = 1
12this.controllable = 0
13this.speed = 2
14
15print(">>> Entity Created - "..this.actorname);
16
17function 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
47end
48
49function this.act(this)
50 this:walk()
51end
52
53--END