4 static Mapa
* mapa
= NULL
;
6 static int regmap (lua_State
*L
) {
7 double width
= lua_tonumber(L
, 1);
8 double height
= lua_tonumber(L
, 2);
10 spawn
.x
= lua_tonumber(L
, 3);
11 spawn
.y
= lua_tonumber(L
, 4);
12 mapa
->setSpawn(spawn
);
13 mapa
->setTamanho(width
,height
);
17 static int regplatform (lua_State
*L
) {
18 mapa
->novaPlataforma(luaL_checknumber(L
, 1),
19 luaL_checknumber(L
, 2),
20 luaL_checknumber(L
, 3),
21 luaL_checknumber(L
, 4),
23 luaL_checknumber(L
, 6),
24 luaL_checknumber(L
, 7),
25 luaL_checknumber(L
, 8));
29 static int regweapon (lua_State
*L
) {
30 const char* nome
= lua_tostring(L
, 1);
31 double x
= lua_tonumber(L
, 2);
32 double y
= lua_tonumber(L
, 3);
33 mapa
->dropWeapon(nome
, Ponto(x
, y
));
37 static int regenemy (lua_State
*L
) {
38 std::string nome
= lua_tostring(L
, 1);
39 double x
= lua_tonumber(L
, 2);
40 double y
= lua_tonumber(L
, 3);
41 mapa
->game
->spawnEnemy(nome
, Ponto(x
, y
));
45 void MapLoader::load(std::string name
, Mapa
* m
) {
47 lua_State
* l
= newState();
48 registerFunction(l
,"regmap",regmap
);
49 registerFunction(l
,"regplatform",regplatform
);
50 registerFunction(l
,"regweapon",regweapon
);
51 registerFunction(l
,"regenemy",regenemy
);
52 doLuaFile(l
,"maploader.lua");
53 doLuaFile(l
,name
.c_str());