1 --Configuration for the Main Actor
2 this.actorname = "Main Character"
3 this.enemy = enemy_neutral
4 this.controllable = true
11 --Experimental Configuration for new Physics Engine.
12 this.jump_strength = 10
16 print(">>> Entity Created - "..this.actorname);
18 function this.jump(this)
19 if not this:get_jumplock()
20 --and this:can_move(up,this:get_x()-this:get_ownspeed(),this:get_y()+this:get_vertical_speed())
21 and not this:can_move(down,this:get_x()-this:get_ownspeed(),this:get_y()) then
22 this:set_vertical_speed(this:get_vertical_speed()-this.jumpstrength)
26 function this.centermap(this)
29 --This is the map center. Set it.
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 --Unless of course we're at one of the edges.
34 if this:get_map_sx() < 0 then
36 elseif this:get_map_sx() + this:get_cfg_screen_width() >= this:get_cfg_max_map_w()*this:get_cfg_tile_w() then
37 this:set_map_sx(this:get_cfg_max_map_w()*this:get_cfg_tile_w() - this:get_cfg_screen_width())
40 if this:get_map_sy() < 0 then
42 elseif this:get_map_sy() + this:get_cfg_screen_height() >= this:get_cfg_max_map_h()*this:get_cfg_tile_h() then
43 this:set_map_sy(this:get_cfg_max_map_h()*this:get_cfg_tile_h() - this:get_cfg_screen_height())
47 function this.handleinput(this)
48 if (this:get_leftkey() > 0 and (this:get_leftkey() > this:get_rightkey() or this:get_rightkey() == 0)) then
49 this:accelerate(-this.walk_acc, -this.walk_speed)
50 --this:set_ownspeed(-this.speed)
52 this:set_currentdirection(left)
55 if (this:get_rightkey() > 0 and (this:get_rightkey() > this:get_leftkey() or this:get_leftkey() == 0)) then
56 this:accelerate(this.walk_acc, this.walk_speed)
57 --this:set_ownspeed(this.speed)
59 this:set_currentdirection(right)
62 if (this:get_rightkey() == 0 and this:get_leftkey() == 0) then
63 this:decelerate(this.walk_acc)
64 --this:set_ownspeed(0)
65 --this:set_walk_time(0)
68 if (this:get_xkey() > 0) then
69 if not this:get_jumplock() then
71 this:set_jumplock(true)
74 this:set_jumplock(false)
75 if(this:get_vertical_speed() < -1) then
76 this:set_vertical_speed(-1)
80 if (this:get_zkey() > 0) then
81 if not this:get_shootlock() and this:get_shotcount() < this.shotlimit then
82 if this.currentweapon == 0 then
83 this:add_bullet("./sprites/shotsprite.png","./scripts/shot.lua")
85 if this.currentweapon == 1 then
86 this:add_bullet("./sprites/shotsprite.png","./scripts/shot-crawl.lua")
88 if this.currentweapon == 2 then
89 this:add_bullet("./sprites/shotsprite.png","./scripts/shot-wave.lua")
91 this:set_shootlock(true)
94 this:set_shootlock(false)
97 if (this:get_ckey() > 0) then
98 if not this:get_switchlock() then
99 this.currentweapon = (this.currentweapon + 1) % 3
100 print ("current weapon is: "..this.currentweapon)
101 this:set_switchlock(true)
104 this:set_switchlock(false)
108 function this.act(this)