diff options
| author | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
| commit | 10a0e290ac07524dc129cc2b227b0f9e95df0f8e (patch) | |
| tree | ed518c45c45d96e37e28640f745496fffb8e1325 /scripts | |
first commit
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/globals.lua | 19 | ||||
| -rw-r--r-- | scripts/main_actor.lua | 112 | ||||
| -rw-r--r-- | scripts/npc_jumper.lua | 20 | ||||
| -rw-r--r-- | scripts/npc_walker.lua | 46 | ||||
| -rw-r--r-- | scripts/shot-crawl.lua | 48 | ||||
| -rw-r--r-- | scripts/shot-wave.lua | 34 | ||||
| -rw-r--r-- | scripts/shot.lua | 33 | ||||
| -rw-r--r-- | scripts/spritesheet.png | bin | 0 -> 10118 bytes |
8 files changed, 312 insertions, 0 deletions
diff --git a/scripts/globals.lua b/scripts/globals.lua new file mode 100644 index 0000000..f5e2c7d --- /dev/null +++ b/scripts/globals.lua @@ -0,0 +1,19 @@ +--the directions +up=0 +right=1 +down=2 +left = 3 + +--the alliances. +enemy_neutral=0 +enemy_evil=1 +enemy_weapon=2 +enemy_superevil=3 + +--sync configuration vars +function this.sync(this) + this:set_physics(this.physics) + this:set_enemy(this.enemy) + this:set_controllable(this.controllable) + this:set_noclip(this.noclip) +end
\ No newline at end of file diff --git a/scripts/main_actor.lua b/scripts/main_actor.lua new file mode 100644 index 0000000..07b5f4d --- /dev/null +++ b/scripts/main_actor.lua @@ -0,0 +1,112 @@ +--Configuration for the Main Actor +this.actorname = "Main Character" +this.enemy = enemy_neutral +this.controllable = true +this.jumpstrength = 14 +this.speed = 6 +this.shotlimit = 3 +this.physics = true +this.currentweapon = 0 + +--Experimental Configuration for new Physics Engine. +this.jump_strength = 10 +this.walk_speed = 10 +this.walk_acc = .1 + +print(">>> Entity Created - "..this.actorname); + +function this.jump(this) + if not this:get_jumplock() + --and this:can_move(up,this:get_x()-this:get_ownspeed(),this:get_y()+this:get_vertical_speed()) + and not this:can_move(down,this:get_x()-this:get_ownspeed(),this:get_y()) then + this:set_vertical_speed(this:get_vertical_speed()-this.jumpstrength) + end +end + +function this.centermap(this) + + + --This is the map center. Set it. + this:set_map_sx(this:get_x() - this:get_cfg_screen_width()/2) + this:set_map_sy(this:get_y() - this:get_cfg_screen_height()/2) + + --Unless of course we're at one of the edges. + if this:get_map_sx() < 0 then + this:set_map_sx(0) + elseif this:get_map_sx() + this:get_cfg_screen_width() >= this:get_cfg_max_map_w()*this:get_cfg_tile_w() then + this:set_map_sx(this:get_cfg_max_map_w()*this:get_cfg_tile_w() - this:get_cfg_screen_width()) + end + + if this:get_map_sy() < 0 then + this:set_map_sy(0) + elseif this:get_map_sy() + this:get_cfg_screen_height() >= this:get_cfg_max_map_h()*this:get_cfg_tile_h() then + this:set_map_sy(this:get_cfg_max_map_h()*this:get_cfg_tile_h() - this:get_cfg_screen_height()) + end +end + +function this.handleinput(this) + if (this:get_leftkey() > 0 and (this:get_leftkey() > this:get_rightkey() or this:get_rightkey() == 0)) then + this:accelerate(-this.walk_acc, -this.walk_speed) + --this:set_ownspeed(-this.speed) + this:set_oldclip(1) + this:set_currentdirection(left) + end + + if (this:get_rightkey() > 0 and (this:get_rightkey() > this:get_leftkey() or this:get_leftkey() == 0)) then + this:accelerate(this.walk_acc, this.walk_speed) + --this:set_ownspeed(this.speed) + this:set_oldclip(2) + this:set_currentdirection(right) + end + + if (this:get_rightkey() == 0 and this:get_leftkey() == 0) then + this:decelerate(this.walk_acc) + --this:set_ownspeed(0) + --this:set_walk_time(0) + end + + if (this:get_xkey() > 0) then + if not this:get_jumplock() then + this:jump() + this:set_jumplock(true) + end + else + this:set_jumplock(false) + if(this:get_vertical_speed() < -1) then + this:set_vertical_speed(-1) + end + end + + if (this:get_zkey() > 0) then + if not this:get_shootlock() and this:get_shotcount() < this.shotlimit then + if this.currentweapon == 0 then + this:add_bullet("./sprites/shotsprite.png","./scripts/shot.lua") + end + if this.currentweapon == 1 then + this:add_bullet("./sprites/shotsprite.png","./scripts/shot-crawl.lua") + end + if this.currentweapon == 2 then + this:add_bullet("./sprites/shotsprite.png","./scripts/shot-wave.lua") + end + this:set_shootlock(true) + end + else + this:set_shootlock(false) + end + + if (this:get_ckey() > 0) then + if not this:get_switchlock() then + this.currentweapon = (this.currentweapon + 1) % 3 + print ("current weapon is: "..this.currentweapon) + this:set_switchlock(true) + end + else + this:set_switchlock(false) + end +end + +function this.act(this) + this:centermap() + this:handleinput() +end +--END
\ No newline at end of file diff --git a/scripts/npc_jumper.lua b/scripts/npc_jumper.lua new file mode 100644 index 0000000..f58d1ff --- /dev/null +++ b/scripts/npc_jumper.lua @@ -0,0 +1,20 @@ +--Configuration for the Jumper +this.actorname = "Enemy: Jumper" +this.enemy = enemy_evil +this.controllable = false +this.jumpstrength = 6 +this.physics = true + +print(">>> Entity Created - "..this.actorname); + +function this.jump(this) + if (this:get_vertical_speed() == 0 and math.random(150) == 50) then + this:set_vertical_speed(this:get_vertical_speed()-this.jumpstrength) + end +end + +function this.act(this) + this:jump() +end + +--END
\ No newline at end of file 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 diff --git a/scripts/shot-crawl.lua b/scripts/shot-crawl.lua new file mode 100644 index 0000000..01b43dc --- /dev/null +++ b/scripts/shot-crawl.lua @@ -0,0 +1,48 @@ +--parameters +this.actorname = "Bullet: Crawlshot" +this.enemy = enemy_weapon +this.speed = 6 +this.controllable = false +this.physics = true +this.bumpcount = 0 +this.bumplimit = 4 + +print(">>> Entity Created - "..this.actorname); + +function this.move(this) + + if(this:get_currentdirection() == right) then + this:set_ownspeed(this.speed) + end + + if (this:get_currentdirection() == left) then + this:set_ownspeed(-this.speed) + end + + if ( ( not this:can_move(left, this:get_x(), this:get_y()) and this:get_currentdirection() == left ) or + ( not this:can_move(right, this:get_x(), this:get_y()) and this:get_currentdirection() == right ) ) then + this.bumpcount = this.bumpcount + 1 + + this:switchdirection() + if this.bumpcount >= this.bumplimit then + this:set_dying(true) + end + end +end + +function this.switchdirection(this) + + if(this:get_currentdirection() == right) then + this:set_currentdirection(left) + this:set_ownspeed(-this.speed) + elseif (this:get_currentdirection() == left) then + this:set_currentdirection(right) + this:set_ownspeed(this.speed) + end +end + +function this.act(this) + this:move() +end + +--END
\ No newline at end of file diff --git a/scripts/shot-wave.lua b/scripts/shot-wave.lua new file mode 100644 index 0000000..758085b --- /dev/null +++ b/scripts/shot-wave.lua @@ -0,0 +1,34 @@ +--parameters +this.actorname = "Bullet: Wave" +this.enemy = enemy_weapon +this.speed = 10 +this.controllable = false +this.physics = false +this.angle = 0 +this.noclip = true + +print(">>> Entity Created - "..this.actorname); + +function this.move(this) + + if(this:get_currentdirection() == right) then + this:set_ownspeed(this.speed) + end + + if (this:get_currentdirection() == left) then + this:set_ownspeed(-this.speed) + end + + this:set_y(this:get_y()+ (10 * math.sin(math.rad(this.angle))) ) + this.angle = this.angle + 45 + + if ( this:get_x() < this:get_map_sx() or this:get_x() > this:get_map_sx() + this:get_cfg_screen_width()) then + this:set_dying(true) + end +end + +function this.act(this) + this:move() +end + +--END
\ No newline at end of file diff --git a/scripts/shot.lua b/scripts/shot.lua new file mode 100644 index 0000000..3077f08 --- /dev/null +++ b/scripts/shot.lua @@ -0,0 +1,33 @@ +--parameters +this.actorname = "Bullet: Normal" +this.enemy = enemy_weapon +this.speed = 6 +this.controllable = false +this.physics = false + +this:load_clip("./sfx/shot.wav"); +this:play_sfx("./sfx/shot.wav"); + +print(">>> Entity Created - "..this.actorname); + +function this.move(this) + + if(this:get_currentdirection() == right) then + this:set_ownspeed(this.speed) + end + + if (this:get_currentdirection() == left) then + this:set_ownspeed(-this.speed) + end + + if ( not this:can_move(left, this:get_x(), this:get_y()) or + not this:can_move(right, this:get_x(), this:get_y())) then + this:set_dying(true) + end +end + +function this.act(this) + this:move() +end + +--END
\ No newline at end of file diff --git a/scripts/spritesheet.png b/scripts/spritesheet.png Binary files differnew file mode 100644 index 0000000..b35cd95 --- /dev/null +++ b/scripts/spritesheet.png |