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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -92,15 +92,26 @@ SDL_Renderer* luaL_checksdlrenderer(lua_State *L)
|
|||
static int
|
||||
l_map_set_current_room_modifier(lua_State *L)
|
||||
{
|
||||
const char *modifier;
|
||||
const char *modifier, *direction;
|
||||
|
||||
Map *map = luaL_checkmap(L, 1);
|
||||
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) {
|
||||
Room *room = map->rooms[map->currentRoom.x][map->currentRoom.y];
|
||||
room->modifier.type = RMOD_TYPE_WINDY;
|
||||
room->modifier.data.wind.direction = VECTOR2D_LEFT;
|
||||
room->modifier.data.wind.direction = dir;
|
||||
} else {
|
||||
luaL_error(L, "Unknown room modifier: %s", modifier);
|
||||
return 1;
|
||||
|
|
|
@ -9,5 +9,6 @@ vector2d_equals(Vector2d v1, Vector2d v2)
|
|||
bool
|
||||
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