Ajuste leve na velocidade permitindo movimentos mais sutis
[Projeto-PCG.git] / maploader.cpp
blob710741878354dd26af19c7d71561a8ae58a6809b
1 #include "maploader.h"
2 #include "luaenv.h"
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);
9 Ponto spawn;
10 spawn.x = lua_tonumber(L, 3);
11 spawn.y = lua_tonumber(L, 4);
12 mapa->setSpawn(spawn);
13 mapa->setTamanho(width,height);
14 return 0;
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),
22 lua_toboolean(L, 5),
23 luaL_checknumber(L, 6),
24 luaL_checknumber(L, 7),
25 luaL_checknumber(L, 8));
26 return 0;
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));
34 return 0;
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));
42 return 0;
45 void MapLoader::load(std::string name, Mapa* m) {
46 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());
54 lua_close(l);