]>
git.r.bdr.sh - rbdr/pico-engine/blob - actor.cpp
3 Actor::Actor(int xpos
, int ypos
, const char *spritepath
, const char *scriptpath
, Map
*map
, Audio
*audio
, Game_overwatch
*ow
, CLuaVirtualMachine
& vm
) : CLuaScript(vm
){
4 this->init(xpos
,ypos
,spritepath
,scriptpath
,NULL
,LEFT
,true,map
,audio
,ow
,vm
);
7 Actor::Actor(int xpos
, int ypos
, const char *spritepath
, const char *scriptpath
, Actor
*dad
, Direction dir
, bool phys
, Map
*map
, Audio
*audio
, Game_overwatch
*ow
, CLuaVirtualMachine
& vm
) : CLuaScript(vm
){
8 this->init(xpos
,ypos
,spritepath
,scriptpath
,dad
,dir
,phys
,map
,audio
,ow
,vm
);
12 SDL_FreeSurface(sprite
);
14 parent
->remove_bullet();
16 overwatch
->move_out(this);
19 void Actor::init(int xpos
, int ypos
, const char *spritepath
, const char *scriptpath
, Actor
*dad
, Direction dir
, bool phys
, Map
*map
, Audio
*aud
, Game_overwatch
*ow
, CLuaVirtualMachine
& vm
){
20 //Set Values from constructor
28 currentdirection
= dir
;
32 SDL_Surface
*raw_sprite
= IMG_Load(spritepath
);
33 sprite
= SDL_DisplayFormat(raw_sprite
);
34 SDL_FreeSurface(raw_sprite
);
35 Uint32 colorkey
= SDL_MapRGB(sprite
->format
, 255, 0, 255);
36 SDL_SetColorKey(sprite
, SDL_SRCCOLORKEY
| SDL_RLEACCEL
, colorkey
); //le ponemos al buddy el colorkey para las transparencias
37 w
= sprite
->w
/SPRITE_FRAMES_W
; //el ancho de nuestro spritesheet
38 h
= sprite
->h
/SPRITE_FRAMES_H
; //lo alto de nuestro spritesheet
41 m_iMethodBase
= RegisterFunction ("get_x");
42 RegisterFunction ("get_y");
43 RegisterFunction ("get_w");
44 RegisterFunction ("get_h");
45 RegisterFunction ("get_clip_x");
46 RegisterFunction ("get_clip_y");
47 RegisterFunction ("get_currentframe");
48 RegisterFunction ("get_oldclip");
49 RegisterFunction ("get_vertical_speed");
50 RegisterFunction ("get_falltime");
51 RegisterFunction ("get_speed");
52 RegisterFunction ("get_ownspeed");
53 RegisterFunction ("get_totalspeed");
54 RegisterFunction ("set_x");
55 RegisterFunction ("set_y");
56 RegisterFunction ("set_w");
57 RegisterFunction ("set_h");
58 RegisterFunction ("set_clip_x");
59 RegisterFunction ("set_clip_y");
60 RegisterFunction ("set_currentframe");
61 RegisterFunction ("set_oldclip");
62 RegisterFunction ("set_vertical_speed");
63 RegisterFunction ("set_falltime");
64 RegisterFunction ("set_speed");
65 RegisterFunction ("set_ownspeed");
66 RegisterFunction ("set_totalspeed");
67 RegisterFunction ("get_currentdirection");
68 RegisterFunction ("set_currentdirection");
69 RegisterFunction ("can_move");
70 RegisterFunction ("get_collision");
71 RegisterFunction ("set_collision");
72 RegisterFunction ("get_map_sx");
73 RegisterFunction ("get_map_sy");
74 RegisterFunction ("set_map_sx");
75 RegisterFunction ("set_map_sy");
76 RegisterFunction ("get_cfg_max_map_w");
77 RegisterFunction ("get_cfg_max_map_h");
78 RegisterFunction ("get_cfg_screen_width");
79 RegisterFunction ("get_cfg_screen_height");
80 RegisterFunction ("get_leftkey");
81 RegisterFunction ("get_rightkey");
82 RegisterFunction ("get_zkey");
83 RegisterFunction ("get_xkey");
84 RegisterFunction ("get_jumplock");
85 RegisterFunction ("get_shootlock");
86 RegisterFunction ("set_jumplock");
87 RegisterFunction ("set_shootlock");
88 RegisterFunction ("set_dying");
89 RegisterFunction ("add_bullet");
90 RegisterFunction ("get_shotcount");
91 RegisterFunction ("set_physics");
92 RegisterFunction ("set_enemy");
93 RegisterFunction ("set_controllable");
94 RegisterFunction ("get_ckey");
95 RegisterFunction ("get_switchlock");
96 RegisterFunction ("set_switchlock");
97 RegisterFunction ("set_noclip");
98 RegisterFunction ("load_clip");
99 RegisterFunction ("play_sfx");
100 RegisterFunction ("play_bgm");
101 RegisterFunction ("stop_bgm");
102 RegisterFunction ("get_cfg_tile_w");
103 RegisterFunction ("get_cfg_tile_h");
104 RegisterFunction ("accelerate");
105 RegisterFunction ("get_walk_time");
106 RegisterFunction ("set_walk_time");
107 RegisterFunction ("decelerate");
111 this->CompileFile("scripts/globals.lua");
112 this->CompileFile (scriptpath
);
115 this->SelectScriptFunction ("sync");
121 vertical_speed
= 0.0;
133 //using ENUM direction as colliding vector index.
134 colliding
[UP
], colliding
[DOWN
], colliding
[LEFT
], colliding
[RIGHT
] = false;
136 overwatch
->move_in(this);
139 //The Lua ScriptCalling Index.
140 int Actor::ScriptCalling (CLuaVirtualMachine
& vm
, int iFunctionNumber
){
141 switch (iFunctionNumber
- m_iMethodBase
)
160 return lget_clip_x(vm
);
164 return lget_clip_y(vm
);
168 return lget_currentframe(vm
);
172 return lget_oldclip(vm
);
176 return lget_vertical_speed(vm
);
180 return lget_falltime(vm
);
184 return lget_speed(vm
);
188 return lget_ownspeed(vm
);
192 return lget_totalspeed(vm
);
211 return lset_clip_x(vm
);
215 return lset_clip_y(vm
);
219 return lset_currentframe(vm
);
223 return lset_oldclip(vm
);
227 return lset_vertical_speed(vm
);
231 return lset_falltime(vm
);
235 return lset_speed(vm
);
239 return lset_ownspeed(vm
);
243 return lset_totalspeed(vm
);
247 return lget_currentdirection(vm
);
251 return lset_currentdirection(vm
);
255 return lcan_move(vm
);
259 return lget_collision(vm
);
263 return lset_collision(vm
);
267 return lget_map_sx(vm
);
271 return lget_map_sy(vm
);
275 return lset_map_sx(vm
);
279 return lset_map_sy(vm
);
283 return lget_cfg_max_map_w(vm
);
287 return lget_cfg_max_map_h(vm
);
291 return lget_cfg_screen_width(vm
);
295 return lget_cfg_screen_height(vm
);
299 return lget_leftkey(vm
);
303 return lget_rightkey(vm
);
307 return lget_zkey(vm
);
311 return lget_xkey(vm
);
315 return lget_jumplock(vm
);
319 return lget_shootlock(vm
);
323 return lset_jumplock(vm
);
327 return lset_shootlock(vm
);
331 return lset_dying(vm
);
335 return ladd_bullet(vm
);
339 return lget_shotcount(vm
);
343 return lset_physics(vm
);
347 return lset_enemy(vm
);
351 return lset_controllable(vm
);
355 return lget_ckey(vm
);
359 return lget_switchlock(vm
);
363 return lset_switchlock(vm
);
367 return lset_noclip(vm
);
371 return lload_clip(vm
);
375 return lplay_sfx(vm
);
379 return lplay_bgm(vm
);
383 return lstop_bgm(vm
);
387 return lget_cfg_tile_w(vm
);
391 return lget_cfg_tile_h(vm
);
394 return laccelerate(vm
);
397 return lget_walk_time(vm
);
400 return lset_walk_time(vm
);
403 return ldecelerate(vm
);
409 void Actor::HandleReturns (CLuaVirtualMachine
& vm
, const char *strFunc
){
413 void Actor::animate(){
415 //check for conditions.
425 if(currentframe
<= MOVEMENT_FREQ
){
432 if(clip_x
>= (w
*SPRITE_FRAMES_W
)-w
){
438 if(animup
){clip_x
+= w
;}else{ clip_x
-= w
;}
444 if (!colliding
[DOWN
]) {
447 totalspeed
= speed
+ ownspeed
;
451 if (totalspeed
> 0 && this->can_move(RIGHT
, x
, y
) ) {
454 if (totalspeed
< 0 && this->can_move(LEFT
, x
, y
) ) {
460 bool Actor::can_move(Direction direction
, int xpos
, int ypos
){
462 if(currentmap
->get_passability((xpos
+5-currentmap
->get_sx()),(ypos
-1-currentmap
->get_sy())) == 1 || currentmap
->get_passability((xpos
+w
-5-currentmap
->get_sx()),(ypos
-1-currentmap
->get_sy())) == 1 || colliding
[UP
]){
466 if(direction
== RIGHT
){
467 if(currentmap
->get_passability((xpos
+w
-currentmap
->get_sx()),(ypos
+(h
*.25)-currentmap
->get_sy())) == 1 || currentmap
->get_passability((xpos
+w
-currentmap
->get_sx()),(ypos
+h
-1-currentmap
->get_sy())) == 1 || colliding
[RIGHT
]){
471 if(direction
== DOWN
){
472 if(currentmap
->get_passability((xpos
+5-currentmap
->get_sx()),(ypos
+h
-currentmap
->get_sy())) == 1 || currentmap
->get_passability((xpos
+w
-5-currentmap
->get_sx()),(ypos
+h
-currentmap
->get_sy())) == 1 || colliding
[DOWN
]){
476 if(direction
== LEFT
){
477 if(currentmap
->get_passability((xpos
-currentmap
->get_sx()),(ypos
+(h
*.25)-currentmap
->get_sy())) == 1 || currentmap
->get_passability((xpos
-currentmap
->get_sx()),(ypos
+h
-1-currentmap
->get_sy())) == 1 || colliding
[LEFT
]){
484 bool Actor::can_die(){
486 if(currentmap
->get_tile((x
-currentmap
->get_sx()),(y
-1-currentmap
->get_sy())) == 2 || currentmap
->get_tile((x
+w
-currentmap
->get_sx()),(y
-1-currentmap
->get_sy())) == 2){
489 if(currentmap
->get_tile((x
+1+w
-currentmap
->get_sx()),(y
-currentmap
->get_sy())) == 2 || currentmap
->get_tile((x
+1+w
-currentmap
->get_sx()),(y
+h
-currentmap
->get_sy())) == 2){
492 if(currentmap
->get_tile((x
-currentmap
->get_sx()),(y
+1+h
-currentmap
->get_sy())) == 2 || currentmap
->get_tile((x
+w
-currentmap
->get_sx()),(y
+1+h
-currentmap
->get_sy())) == 2){
495 if(currentmap
->get_tile((x
-1-currentmap
->get_sx()),(y
-currentmap
->get_sy())) == 2 || currentmap
->get_tile((x
-1-currentmap
->get_sx()),(y
+h
-currentmap
->get_sy())) == 2){
501 void Actor::add_bullet(const char* sprite
, const char* script
){
503 if (currentdirection
== LEFT
) {
504 new Actor(x
-14, y
+10,sprite
, script
, this, LEFT
, false, currentmap
, audio
, overwatch
, m_vm
);
506 if (currentdirection
== RIGHT
) {
507 new Actor(x
+w
+4, y
+10,sprite
, script
, this, RIGHT
, false, currentmap
, audio
, overwatch
, m_vm
);
511 void Actor::remove_bullet(){
515 void Actor::accelerate(float accel
, float max_speed
){
517 if ( (accel
> 0 && ownspeed
== max_speed
&& max_speed
< 0) || (accel
< 0 && ownspeed
== max_speed
&& max_speed
> 0) ){
521 //reset the time if we were deccelerating.
526 walk_time
+= 1; //increase the time, because we are accelerating.
528 if((ownspeed
>= max_speed
&& max_speed
> 0) || (ownspeed
<= max_speed
&& max_speed
< 0)){
529 ownspeed
= max_speed
;
531 ownspeed
= ownspeed
+ accel
*walk_time
;
535 void Actor::decelerate(float accel
){
536 if(ownspeed
!= 0 && falltime
== 0){
540 walk_time
-= 1; //increase the time, because we are accelerating.
544 ownspeed
= ownspeed
+ accel
*walk_time
;
546 ownspeed
= 0; //if we go too far, just settle with 0.
550 ownspeed
= ownspeed
- accel
*walk_time
;
552 ownspeed
= 0; //if we go too far, just settle with 0.
560 int Actor::get_x(void){ return x
; }
561 void Actor::set_x(int newval
){ x
= newval
; }
562 int Actor::get_y(void){ return y
; }
563 void Actor::set_y(int newval
){ y
= newval
; }
564 int Actor::get_w(void){ return w
; }
565 void Actor::set_w(int newval
){ w
= newval
; }
566 int Actor::get_h(void){ return h
; }
567 void Actor::set_h(int newval
){ h
= newval
; }
568 int Actor::get_clip_x(void){ return clip_x
; }
569 void Actor::set_clip_x(int newval
){ clip_x
= newval
; }
570 int Actor::get_clip_y(void){ return clip_y
; }
571 void Actor::set_clip_y(int newval
){ clip_y
= newval
; }
572 int Actor::get_currentframe(void){ return currentframe
; }
573 void Actor::set_currentframe(int newval
){ currentframe
= newval
; }
574 int Actor::get_oldclip(void){ return oldclip
; }
575 void Actor::set_oldclip(int newval
){ oldclip
= newval
; }
576 float Actor::get_vertical_speed(void){ return vertical_speed
; }
577 void Actor::set_vertical_speed(float newval
){ vertical_speed
= newval
;}
578 float Actor::get_vertical_acc(void){ return vertical_acc
; }
579 void Actor::set_vertical_acc(float newval
){ vertical_acc
= newval
;}
580 float Actor::get_falltime(void){ return falltime
; }
581 void Actor::set_falltime(float newval
){ falltime
= newval
; }
582 SDL_Surface
* Actor::get_sprite(void){ return sprite
; }
583 float Actor::get_speed(void){ return speed
; }
584 void Actor::set_speed(float newval
){ speed
= newval
;}
585 float Actor::get_ownspeed(void){ return ownspeed
; }
586 void Actor::set_ownspeed(float newval
){ ownspeed
= newval
;}
587 float Actor::get_totalspeed(void){ return totalspeed
; }
588 void Actor::set_totalspeed(float newval
){ totalspeed
= newval
;}
589 float Actor::get_horizontal_acc(void){ return vertical_acc
; }
590 void Actor::set_horizontal_acc(float newval
){ vertical_acc
= newval
;}
591 Direction
Actor::get_currentdirection(void){ return currentdirection
; }
592 Enemy
Actor::get_enemy(void){ return enemy
; }
593 int Actor::get_leftkey(void){ return leftkey
; }
594 void Actor::set_leftkey(int newval
){ leftkey
= newval
; }
595 int Actor::get_rightkey(void){ return rightkey
; }
596 void Actor::set_rightkey(int newval
){ rightkey
= newval
; }
597 int Actor::get_zkey(void){ return zkey
; }
598 void Actor::set_zkey(int newval
){ zkey
= newval
; }
599 int Actor::get_xkey(void){ return xkey
; }
600 void Actor::set_xkey(int newval
){ xkey
= newval
; }
601 bool Actor::get_physics(void){ return physics
; }
602 void Actor::set_physics(bool newval
){ physics
= newval
; }
603 void Actor::set_collision(bool col
, int corner
){
604 colliding
[corner
] = col
;
606 bool Actor::get_controllable(void){ return controllable
; }
607 bool Actor::get_collision(int corner
){
608 return colliding
[corner
];
610 bool Actor::get_dying(void){ return dying
; }
611 void Actor::set_dying(bool newval
){ dying
= newval
; }
612 void Actor::set_ckey(int newval
){ ckey
= newval
; }
613 bool Actor::get_noclip(void){ return noclip
; }
615 //lua accessors (get)
616 int Actor::lget_x(CLuaVirtualMachine
& vm
){
617 lua_State
*state
= (lua_State
*) vm
;
618 lua_pushnumber (state
, x
);
622 int Actor::lget_y(CLuaVirtualMachine
& vm
){
623 lua_State
*state
= (lua_State
*) vm
;
624 lua_pushnumber (state
, y
);
628 int Actor::lget_w(CLuaVirtualMachine
& vm
){
629 lua_State
*state
= (lua_State
*) vm
;
630 lua_pushnumber (state
, w
);
634 int Actor::lget_h(CLuaVirtualMachine
& vm
){
635 lua_State
*state
= (lua_State
*) vm
;
636 lua_pushnumber (state
, h
);
640 int Actor::lget_clip_x(CLuaVirtualMachine
& vm
){
641 lua_State
*state
= (lua_State
*) vm
;
642 lua_pushnumber (state
, clip_x
);
646 int Actor::lget_clip_y(CLuaVirtualMachine
& vm
){
647 lua_State
*state
= (lua_State
*) vm
;
648 lua_pushnumber (state
, clip_y
);
652 int Actor::lget_currentframe(CLuaVirtualMachine
& vm
){
653 lua_State
*state
= (lua_State
*) vm
;
654 lua_pushnumber (state
, currentframe
);
658 int Actor::lget_oldclip(CLuaVirtualMachine
& vm
){
659 lua_State
*state
= (lua_State
*) vm
;
660 lua_pushnumber (state
, oldclip
);
664 int Actor::lget_vertical_speed(CLuaVirtualMachine
& vm
){
665 lua_State
*state
= (lua_State
*) vm
;
666 lua_pushnumber (state
, vertical_speed
);
670 int Actor::lget_falltime(CLuaVirtualMachine
& vm
){
671 lua_State
*state
= (lua_State
*) vm
;
672 lua_pushnumber (state
, falltime
);
676 int Actor::lget_speed(CLuaVirtualMachine
& vm
){
677 lua_State
*state
= (lua_State
*) vm
;
678 lua_pushnumber (state
, speed
);
682 int Actor::lget_ownspeed(CLuaVirtualMachine
& vm
){
683 lua_State
*state
= (lua_State
*) vm
;
684 lua_pushnumber (state
, ownspeed
);
688 int Actor::lget_totalspeed(CLuaVirtualMachine
& vm
){
689 lua_State
*state
= (lua_State
*) vm
;
690 lua_pushnumber (state
, totalspeed
);
694 int Actor::lget_currentdirection(CLuaVirtualMachine
& vm
){
695 lua_State
*state
= (lua_State
*) vm
;
696 lua_pushnumber (state
, currentdirection
);
700 int Actor::lget_collision(CLuaVirtualMachine
& vm
){
701 lua_State
*state
= (lua_State
*) vm
;
702 lua_pushboolean (state
, colliding
[(int) lua_tonumber (state
, -1)]);
706 int Actor::lget_map_sx(CLuaVirtualMachine
& vm
){
707 lua_State
*state
= (lua_State
*) vm
;
708 lua_pushnumber (state
, currentmap
->get_sx());
712 int Actor::lget_map_sy(CLuaVirtualMachine
& vm
){
713 lua_State
*state
= (lua_State
*) vm
;
714 lua_pushnumber (state
, currentmap
->get_sy());
718 int Actor::lget_cfg_max_map_w(CLuaVirtualMachine
& vm
){
719 lua_State
*state
= (lua_State
*) vm
;
720 lua_pushnumber (state
, MAX_MAP_W
);
724 int Actor::lget_cfg_max_map_h(CLuaVirtualMachine
& vm
){
725 lua_State
*state
= (lua_State
*) vm
;
726 lua_pushnumber (state
, MAX_MAP_H
);
730 int Actor::lget_cfg_tile_h(CLuaVirtualMachine
& vm
){
731 lua_State
*state
= (lua_State
*) vm
;
732 lua_pushnumber (state
, TILE_HEIGHT
);
736 int Actor::lget_cfg_screen_height(CLuaVirtualMachine
& vm
){
737 lua_State
*state
= (lua_State
*) vm
;
738 lua_pushnumber (state
, SCREEN_HEIGHT
);
742 int Actor::lget_leftkey(CLuaVirtualMachine
& vm
){
743 lua_State
*state
= (lua_State
*) vm
;
744 lua_pushnumber (state
, leftkey
);
748 int Actor::lget_rightkey(CLuaVirtualMachine
& vm
){
749 lua_State
*state
= (lua_State
*) vm
;
750 lua_pushnumber (state
, rightkey
);
754 int Actor::lget_zkey(CLuaVirtualMachine
& vm
){
755 lua_State
*state
= (lua_State
*) vm
;
756 lua_pushnumber (state
, zkey
);
760 int Actor::lget_xkey(CLuaVirtualMachine
& vm
){
761 lua_State
*state
= (lua_State
*) vm
;
762 lua_pushnumber (state
, xkey
);
766 int Actor::lget_jumplock(CLuaVirtualMachine
& vm
){
767 lua_State
*state
= (lua_State
*) vm
;
768 lua_pushboolean (state
, jumplock
);
772 int Actor::lget_shootlock(CLuaVirtualMachine
& vm
){
773 lua_State
*state
= (lua_State
*) vm
;
774 lua_pushboolean (state
, shootlock
);
778 int Actor::lget_shotcount(CLuaVirtualMachine
& vm
){
779 lua_State
*state
= (lua_State
*) vm
;
780 lua_pushnumber (state
, shotcount
);
784 int Actor::lget_ckey(CLuaVirtualMachine
& vm
){
785 lua_State
*state
= (lua_State
*) vm
;
786 lua_pushnumber (state
, ckey
);
790 int Actor::lget_switchlock(CLuaVirtualMachine
& vm
){
791 lua_State
*state
= (lua_State
*) vm
;
792 lua_pushboolean (state
, switchlock
);
796 int Actor::lget_cfg_tile_w(CLuaVirtualMachine
& vm
){
797 lua_State
*state
= (lua_State
*) vm
;
798 lua_pushnumber (state
, TILE_WIDTH
);
802 int Actor::lget_cfg_screen_width(CLuaVirtualMachine
& vm
){
803 lua_State
*state
= (lua_State
*) vm
;
804 lua_pushnumber (state
, SCREEN_WIDTH
);
808 int Actor::lget_walk_time(CLuaVirtualMachine
& vm
){
809 lua_State
*state
= (lua_State
*) vm
;
810 lua_pushnumber (state
, walk_time
);
814 //lua accessors (set)
815 int Actor::lset_x(CLuaVirtualMachine
& vm
){
816 lua_State
*state
= (lua_State
*) vm
;
817 x
= (int) lua_tonumber (state
, -1);
821 int Actor::lset_y(CLuaVirtualMachine
& vm
){
822 lua_State
*state
= (lua_State
*) vm
;
823 y
= (int) lua_tonumber (state
, -1);
827 int Actor::lset_w(CLuaVirtualMachine
& vm
){
828 lua_State
*state
= (lua_State
*) vm
;
829 w
= (int) lua_tonumber (state
, -1);
833 int Actor::lset_h(CLuaVirtualMachine
& vm
){
834 lua_State
*state
= (lua_State
*) vm
;
835 h
= (int) lua_tonumber (state
, -1);
839 int Actor::lset_clip_x(CLuaVirtualMachine
& vm
){
840 lua_State
*state
= (lua_State
*) vm
;
841 clip_x
= (int) lua_tonumber (state
, -1);
845 int Actor::lset_clip_y(CLuaVirtualMachine
& vm
){
846 lua_State
*state
= (lua_State
*) vm
;
847 clip_y
= (int) lua_tonumber (state
, -1);
851 int Actor::lset_currentframe(CLuaVirtualMachine
& vm
){
852 lua_State
*state
= (lua_State
*) vm
;
853 currentframe
= (int) lua_tonumber (state
, -1);
857 int Actor::lset_oldclip(CLuaVirtualMachine
& vm
){
858 lua_State
*state
= (lua_State
*) vm
;
859 oldclip
= (int) lua_tonumber (state
, -1);
863 int Actor::lset_vertical_speed(CLuaVirtualMachine
& vm
){
864 lua_State
*state
= (lua_State
*) vm
;
865 vertical_speed
= (float) lua_tonumber (state
, -1);
869 int Actor::lset_falltime(CLuaVirtualMachine
& vm
){
870 lua_State
*state
= (lua_State
*) vm
;
871 falltime
= (float) lua_tonumber (state
, -1);
875 int Actor::lset_speed(CLuaVirtualMachine
& vm
){
876 lua_State
*state
= (lua_State
*) vm
;
877 speed
= (float) lua_tonumber (state
, -1);
881 int Actor::lset_ownspeed(CLuaVirtualMachine
& vm
){
882 lua_State
*state
= (lua_State
*) vm
;
883 ownspeed
= (float) lua_tonumber (state
, -1);
887 int Actor::lset_totalspeed(CLuaVirtualMachine
& vm
){
888 lua_State
*state
= (lua_State
*) vm
;
889 totalspeed
= (float) lua_tonumber (state
, -1);
893 int Actor::lset_currentdirection(CLuaVirtualMachine
& vm
){
894 lua_State
*state
= (lua_State
*) vm
;
895 currentdirection
= (Direction
) lua_tonumber (state
, -1);
899 int Actor::lset_collision(CLuaVirtualMachine
& vm
){
900 lua_State
*state
= (lua_State
*) vm
;
901 colliding
[(int) lua_tonumber (state
, -1)] = (bool) lua_toboolean(state
, -2);
905 int Actor::lset_map_sx(CLuaVirtualMachine
& vm
){
906 lua_State
*state
= (lua_State
*) vm
;
907 currentmap
->set_sx((int) lua_tonumber (state
, -1));
911 int Actor::lset_map_sy(CLuaVirtualMachine
& vm
){
912 lua_State
*state
= (lua_State
*) vm
;
913 currentmap
->set_sy((int) lua_tonumber (state
, -1));
917 int Actor::lset_jumplock(CLuaVirtualMachine
& vm
){
918 lua_State
*state
= (lua_State
*) vm
;
919 jumplock
= (bool) lua_toboolean (state
, -1);
923 int Actor::lset_shootlock(CLuaVirtualMachine
& vm
){
924 lua_State
*state
= (lua_State
*) vm
;
925 shootlock
= (bool) lua_toboolean (state
, -1);
929 int Actor::lset_dying(CLuaVirtualMachine
& vm
){
930 lua_State
*state
= (lua_State
*) vm
;
931 dying
= (bool) lua_toboolean (state
, -1);
935 int Actor::lset_physics(CLuaVirtualMachine
& vm
){
936 lua_State
*state
= (lua_State
*) vm
;
937 physics
= (bool) lua_toboolean (state
, -1);
941 int Actor::lset_enemy(CLuaVirtualMachine
& vm
){
942 lua_State
*state
= (lua_State
*) vm
;
943 enemy
= (Enemy
) lua_tonumber (state
, -1);
947 int Actor::lset_controllable(CLuaVirtualMachine
& vm
){
948 lua_State
*state
= (lua_State
*) vm
;
949 controllable
= (bool) lua_toboolean (state
, -1);
953 int Actor::lset_switchlock(CLuaVirtualMachine
& vm
){
954 lua_State
*state
= (lua_State
*) vm
;
955 switchlock
= (bool) lua_toboolean (state
, -1);
959 int Actor::lset_noclip(CLuaVirtualMachine
& vm
){
960 lua_State
*state
= (lua_State
*) vm
;
961 noclip
= (bool) lua_toboolean (state
, -1);
965 int Actor::lset_walk_time(CLuaVirtualMachine
& vm
){
966 lua_State
*state
= (lua_State
*) vm
;
967 walk_time
= (int) lua_tonumber (state
, -1);
974 int Actor::lcan_move(CLuaVirtualMachine
& vm
){
975 lua_State
*state
= (lua_State
*) vm
;
976 lua_pushboolean(state
,this->can_move((Direction
) lua_tonumber (state
, -3), (int) lua_tonumber (state
, -2), (int) lua_tonumber (state
, -1)));
980 int Actor::ladd_bullet(CLuaVirtualMachine
& vm
){
981 lua_State
*state
= (lua_State
*) vm
;
982 this->add_bullet((const char*) lua_tostring (state
, -2), (const char*) lua_tostring (state
, -1));
986 int Actor::lload_clip(CLuaVirtualMachine
& vm
){
987 lua_State
*state
= (lua_State
*) vm
;
988 audio
->load_clip((const char*) lua_tostring (state
, -1));
992 int Actor::lplay_sfx(CLuaVirtualMachine
& vm
){
993 lua_State
*state
= (lua_State
*) vm
;
994 audio
->play_sfx((const char*) lua_tostring (state
, -1));
998 int Actor::lplay_bgm(CLuaVirtualMachine
& vm
){
999 lua_State
*state
= (lua_State
*) vm
;
1000 audio
->play_bgm((const char*) lua_tostring (state
, -1));
1004 int Actor::lstop_bgm(CLuaVirtualMachine
& vm
){
1005 lua_State
*state
= (lua_State
*) vm
;
1006 audio
->stop_bgm((const char*) lua_tostring (state
, -1));
1010 int Actor::laccelerate(CLuaVirtualMachine
& vm
){
1011 lua_State
*state
= (lua_State
*) vm
;
1012 this->accelerate((float) lua_tonumber (state
, -2), (float) lua_tonumber (state
, -1));
1016 int Actor::ldecelerate(CLuaVirtualMachine
& vm
){
1017 lua_State
*state
= (lua_State
*) vm
;
1018 this->decelerate((float) lua_tonumber (state
, -1));