From 10a0e290ac07524dc129cc2b227b0f9e95df0f8e Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 16 Apr 2012 09:39:52 -0500 Subject: first commit --- .../Contents/Resources/npc_walker.lua | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua (limited to 'build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua') diff --git a/build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua b/build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua new file mode 100644 index 0000000..eb920b1 --- /dev/null +++ b/build/Debug/Pico-Lua-Test.app/Contents/Resources/npc_walker.lua @@ -0,0 +1,53 @@ +--Configuration for the Jumper +this.actorname = "Enemy: Walker" + +--the directions +up=0 +right=1 +down=2 +left = 3 + +--parameters +this.enemy = 1 +this.controllable = 0 +this.speed = 2 + +print(">>> Entity Created - "..this.actorname); + +function this.walk(this) + if(this:get_currentdirection() == left) then + if ( this:can_move(left, this:get_x(), this:get_y()) and + not this:can_move(down, this:get_x()+this:get_ownspeed(), this:get_y())) then + if this:get_collision(left) then + this:set_currentdirection(right) + else + this:set_ownspeed(-this.speed) + end + this:set_oldclip(1) + else + this:set_currentdirection(right) + this:set_ownspeed(this.speed) + end + end + + if(this:get_currentdirection() == right) then + if ( this:can_move(right, this:get_x(), this:get_y()) and + not this:can_move(down, this:get_x()+this:get_ownspeed(), this:get_y())) then + if this:get_collision(right) then + this:set_currentdirection(left) + else + this:set_ownspeed(this.speed) + end + this:set_oldclip(2) + else + this:set_currentdirection(left) + this:set_ownspeed(-this.speed) + end + end +end + +function this.act(this) + this:walk() +end + +--END \ No newline at end of file -- cgit