1 --Configuration for the Main Actor
2 --Also, this is pretty arbitrary: walksound=0 (for the audio track switches)
11 this.actorname = "Main Character"
18 print(">>> Entity Created - "..this.actorname);
20 function this.jump(this)
21 if not this:get_jumplock()
22 and this:can_move(0,this:get_x(),this:get_y())
23 and not this:can_move(2,this:get_x(),this:get_y()) then
24 this:set_vertical_speed(this:get_vertical_speed()-this.jumpstrength)
28 function this.centermap(this)
30 this:set_map_sx(this:get_x() - this:get_cfg_screen_width()/2)
31 this:set_map_sy(this:get_y() - this:get_cfg_screen_height()/2)
33 if this:get_map_sx() < 0 then
35 elseif this:get_map_sx() + this:get_cfg_screen_width() >= this:get_cfg_max_map_w()*25 then
36 this:set_map_sx(this:get_cfg_max_map_w()*25 - this:get_cfg_screen_width())
39 if this:get_map_sy() < 0 then
41 elseif this:get_map_sy() + this:get_cfg_screen_height() >= this:get_cfg_max_map_h()*25 then
42 this:set_map_sy(this:get_cfg_max_map_h()*25 - this:get_cfg_screen_height())
46 function this.handleinput(this)
47 if (this:get_leftkey() > 0 and (this:get_leftkey() > this:get_rightkey() or this:get_rightkey() == 0)) then
48 this:set_ownspeed(-this.speed)
50 this:set_currentdirection(left)
53 if (this:get_rightkey() > 0 and (this:get_rightkey() > this:get_leftkey() or this:get_leftkey() == 0)) then
54 this:set_ownspeed(this.speed)
56 this:set_currentdirection(right)
59 if (this:get_rightkey() == 0 and this:get_leftkey() == 0) then
63 if (this:get_xkey() > 0) then
64 if not this:get_jumplock() then
66 this:set_jumplock(true)
69 this:set_jumplock(false)
70 if(this:get_vertical_speed() < -1) then
71 this:set_vertical_speed(-1)
75 if (this:get_zkey() > 0) then
76 if not this:get_shootlock() and this:get_shotcount() < this.shotlimit then
77 this:add_bullet("./shotsprite.png","./shot.lua")
78 this:set_shootlock(true)
81 this:set_shootlock(false)
85 function this.act(this)