aboutsummaryrefslogtreecommitdiff
path: root/scripts/npc_walker.lua
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2012-04-16 09:39:52 -0500
committerBen Beltran <ben@nsovocal.com>2012-04-16 09:39:52 -0500
commit10a0e290ac07524dc129cc2b227b0f9e95df0f8e (patch)
treeed518c45c45d96e37e28640f745496fffb8e1325 /scripts/npc_walker.lua
first commit
Diffstat (limited to 'scripts/npc_walker.lua')
-rw-r--r--scripts/npc_walker.lua46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/npc_walker.lua b/scripts/npc_walker.lua
new file mode 100644
index 0000000..1537464
--- /dev/null
+++ b/scripts/npc_walker.lua
@@ -0,0 +1,46 @@
+--Configuration for the Jumper
+this.actorname = "Enemy: Walker"
+this.enemy = enemy_evil
+this.controllable = false
+this.speed = 2
+this.physics = true
+
+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