Add direction to windy rooms in lua
This commit is contained in:
parent
2393608682
commit
42fd246185
|
@ -373,7 +373,8 @@ function module.build_square_room(map, room)
|
||||||
end
|
end
|
||||||
|
|
||||||
if CURRENT_LEVEL > 2 and random(10) == 1 then
|
if CURRENT_LEVEL > 2 and random(10) == 1 then
|
||||||
set_modifier(map, "WINDY");
|
directions = { "LEFT", "RIGHT", "UP", "DOWN" }
|
||||||
|
set_modifier(map, "WINDY", directions[random(#directions)]);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -92,15 +92,26 @@ SDL_Renderer* luaL_checksdlrenderer(lua_State *L)
|
||||||
static int
|
static int
|
||||||
l_map_set_current_room_modifier(lua_State *L)
|
l_map_set_current_room_modifier(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *modifier;
|
const char *modifier, *direction;
|
||||||
|
|
||||||
Map *map = luaL_checkmap(L, 1);
|
Map *map = luaL_checkmap(L, 1);
|
||||||
modifier = luaL_checkstring(L, 2);
|
modifier = luaL_checkstring(L, 2);
|
||||||
|
direction = luaL_checkstring(L, 3);
|
||||||
|
|
||||||
|
Vector2d dir = VECTOR2D_LEFT;
|
||||||
|
if (strcmp(direction, "LEFT") == 0)
|
||||||
|
dir = VECTOR2D_LEFT;
|
||||||
|
else if (strcmp(direction, "RIGHT") == 0)
|
||||||
|
dir = VECTOR2D_RIGHT;
|
||||||
|
else if (strcmp(direction, "UP") == 0)
|
||||||
|
dir = VECTOR2D_UP;
|
||||||
|
else if (strcmp(direction, "DOWN") == 0)
|
||||||
|
dir = VECTOR2D_DOWN;
|
||||||
|
|
||||||
if (strcmp(modifier, "WINDY") == 0) {
|
if (strcmp(modifier, "WINDY") == 0) {
|
||||||
Room *room = map->rooms[map->currentRoom.x][map->currentRoom.y];
|
Room *room = map->rooms[map->currentRoom.x][map->currentRoom.y];
|
||||||
room->modifier.type = RMOD_TYPE_WINDY;
|
room->modifier.type = RMOD_TYPE_WINDY;
|
||||||
room->modifier.data.wind.direction = VECTOR2D_LEFT;
|
room->modifier.data.wind.direction = dir;
|
||||||
} else {
|
} else {
|
||||||
luaL_error(L, "Unknown room modifier: %s", modifier);
|
luaL_error(L, "Unknown room modifier: %s", modifier);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -9,5 +9,6 @@ vector2d_equals(Vector2d v1, Vector2d v2)
|
||||||
bool
|
bool
|
||||||
vector2d_is_opposite(Vector2d v1, Vector2d v2)
|
vector2d_is_opposite(Vector2d v1, Vector2d v2)
|
||||||
{
|
{
|
||||||
return (v1.x > 0 && v2.x < 0) ^ (v1.y > 0 && v2.y < 0);
|
return ((v1.x > 0 && v2.x < 0) ^ (v1.y > 0 && v2.y < 0))
|
||||||
|
|| ((v1.x < 0 && v2.x > 0) ^ (v1.y < 0 && v2.y > 0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue