1 --Configuration for the Main Actor
2 this.actorname = "Main Character"
3 this.enemy = enemy_neutral
4 this.controllable = true
5 this.jumpstrength = 5.4
11 print(">>> Entity Created - "..this.actorname);
13 function this.jump(this)
14 if not this:get_jumplock()
15 --and this:can_move(up,this:get_x()-this:get_ownspeed(),this:get_y()+this:get_vertical_speed())
16 and not this:can_move(down,this:get_x()-this:get_ownspeed(),this:get_y()) then
17 this:set_vertical_speed(this:get_vertical_speed()-this.jumpstrength)
21 function this.centermap(this)
23 this:set_map_sx(this:get_x() - this:get_cfg_screen_width()/2)
24 this:set_map_sy(this:get_y() - this:get_cfg_screen_height()/2)
26 if this:get_map_sx() < 0 then
28 elseif this:get_map_sx() + this:get_cfg_screen_width() >= this:get_cfg_max_map_w()*25 then
29 this:set_map_sx(this:get_cfg_max_map_w()*25 - this:get_cfg_screen_width())
32 if this:get_map_sy() < 0 then
34 elseif this:get_map_sy() + this:get_cfg_screen_height() >= this:get_cfg_max_map_h()*25 then
35 this:set_map_sy(this:get_cfg_max_map_h()*25 - this:get_cfg_screen_height())
39 function this.handleinput(this)
40 if (this:get_leftkey() > 0 and (this:get_leftkey() > this:get_rightkey() or this:get_rightkey() == 0)) then
41 this:set_ownspeed(-this.speed)
43 this:set_currentdirection(left)
46 if (this:get_rightkey() > 0 and (this:get_rightkey() > this:get_leftkey() or this:get_leftkey() == 0)) then
47 this:set_ownspeed(this.speed)
49 this:set_currentdirection(right)
52 if (this:get_rightkey() == 0 and this:get_leftkey() == 0) then
56 if (this:get_xkey() > 0) then
57 if not this:get_jumplock() then
59 this:set_jumplock(true)
62 this:set_jumplock(false)
63 if(this:get_vertical_speed() < -1) then
64 this:set_vertical_speed(-1)
68 if (this:get_zkey() > 0) then
69 if not this:get_shootlock() and this:get_shotcount() < this.shotlimit then
70 if this.currentweapon == 0 then
71 this:add_bullet("./shotsprite.png","./scripts/shot.lua")
73 if this.currentweapon == 1 then
74 this:add_bullet("./shotsprite.png","./scripts/shot-crawl.lua")
76 if this.currentweapon == 2 then
77 this:add_bullet("./shotsprite.png","./scripts/shot-wave.lua")
79 this:set_shootlock(true)
82 this:set_shootlock(false)
85 if (this:get_ckey() > 0) then
86 if not this:get_switchlock() then
87 this.currentweapon = (this.currentweapon + 1) % 3
88 print ("current weapon is: "..this.currentweapon)
89 this:set_switchlock(true)
92 this:set_switchlock(false)
96 function this.act(this)