mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-29 17:02:11 +00:00
running on top when near a bomb
This commit is contained in:
@@ -130,12 +130,17 @@ function getPathToSafeSpace(player)
|
||||
end
|
||||
|
||||
------ Update
|
||||
function Update(mapinfo)
|
||||
function Update()
|
||||
log("NEW FRAME")
|
||||
print("a")
|
||||
local dangerMap = getDanger()
|
||||
local path = getPath(0, 0, 16, 16);
|
||||
--local path = getPath(0, 0, 16, 16);
|
||||
local player = getPlayer();
|
||||
local playerRound = getPlayerRound();
|
||||
PrintMap(dangerMap, 17, 17);
|
||||
if isPlayerInDanger() then
|
||||
return 1, 1, false, false
|
||||
end
|
||||
---- sjould send Map Danger and MaxX MaxY
|
||||
--MaxX = 0
|
||||
--MaxY = 0
|
||||
|
||||
+11
-1
@@ -42,7 +42,7 @@ namespace BBM
|
||||
|
||||
void LuaMap::setPlayer(Vector3f pos)
|
||||
{
|
||||
_player = Vector2f(pos.x, pos.y);
|
||||
_player = Vector2f(pos.x, pos.z);
|
||||
_roundedPlayer = Vector2f(std::round(_player.x), std::round(_player.y));
|
||||
}
|
||||
|
||||
@@ -226,4 +226,14 @@ namespace BBM
|
||||
const LuaMap *map = (const LuaMap *) lua_topointer(L, lua_upvalueindex(1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaMap::isPlayerInDanger(lua_State *L)
|
||||
{
|
||||
auto y = lua_tonumber(L, -1);
|
||||
auto x = lua_tonumber(L, -2);
|
||||
LuaG::State state(L);
|
||||
const LuaMap *map = (const LuaMap *) lua_topointer(L, lua_upvalueindex(1));
|
||||
lua_pushboolean(L, map->_danger[map->_roundedPlayer.y][map->_roundedPlayer.x] > 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ namespace BBM
|
||||
//! @brief get closest safe space of player
|
||||
static int getClosestSafeSpace(lua_State *L);
|
||||
|
||||
static int isPlayerInDanger(lua_State *L);
|
||||
|
||||
//! @brief map blocks in 2D grid
|
||||
std::vector<std::vector<int>> _map;
|
||||
|
||||
|
||||
@@ -91,6 +91,10 @@ namespace BBM
|
||||
lua_pushlightuserdata(state.getState(), &_luamap);
|
||||
lua_pushcclosure(state.getState(), LuaMap::getPlayerRound, 1);
|
||||
lua_setglobal(state.getState(), "getPlayerRound");
|
||||
|
||||
lua_pushlightuserdata(state.getState(), &_luamap);
|
||||
lua_pushcclosure(state.getState(), LuaMap::isPlayerInDanger, 1);
|
||||
lua_setglobal(state.getState(), "isPlayerInDanger");
|
||||
}
|
||||
|
||||
void IAControllableSystem::onFixedUpdate(WAL::ViewEntity<PositionComponent, ControllableComponent, IAControllableComponent, BombHolderComponent> &entity)
|
||||
@@ -106,10 +110,13 @@ namespace BBM
|
||||
ia.registered = true;
|
||||
}
|
||||
UpdateMapInfos(entity);
|
||||
std::cout << _luamap._player << std::endl << std::flush;
|
||||
ia._state.getGlobal("Update");
|
||||
if (!lua_isfunction(ia._state.getState(), -1))
|
||||
if (!lua_isfunction(ia._state.getState(), -1)) {
|
||||
std::cout << "a" << std::flush;
|
||||
return;
|
||||
ia._state.callFunction(1, 4);
|
||||
}
|
||||
ia._state.callFunction(0, 4);
|
||||
controllable.bomb = ia._state.getReturnBool();
|
||||
controllable.select = ia._state.getReturnBool();
|
||||
controllable.move.y = ia._state.getReturnNumber();
|
||||
|
||||
Reference in New Issue
Block a user