Fixes missing lights in coridors and exit under candle
Also some improvements to the in game menu handling.
This commit is contained in:
parent
dcafbbc6ac
commit
a045ffc07c
4
TODO.txt
4
TODO.txt
|
@ -26,10 +26,10 @@ x Statistics
|
||||||
x More stuff to count
|
x More stuff to count
|
||||||
x Particle engine for blood splatter (keep it light!!!)
|
x Particle engine for blood splatter (keep it light!!!)
|
||||||
x Prevent level exit from spawning on occupied spot
|
x Prevent level exit from spawning on occupied spot
|
||||||
o Menus
|
x Menus
|
||||||
x Main menu
|
x Main menu
|
||||||
x In game menu
|
x In game menu
|
||||||
- Player death (graphic or text?)
|
- Player death (GAME_OVER state) (graphic or text?)
|
||||||
- Sound?
|
- Sound?
|
||||||
- Make things less difficult and more interesting
|
- Make things less difficult and more interesting
|
||||||
- Interesting items
|
- Interesting items
|
||||||
|
|
|
@ -125,6 +125,12 @@ local function check_add_decoration(map, x, y, data)
|
||||||
add_decoration(map, x, y, repack(data))
|
add_decoration(map, x, y, repack(data))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function check_add_tile(map, x, y, data)
|
||||||
|
if tile_occupied(map, x, y) then return false end
|
||||||
|
add_tile(map, x, y, repack(data))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local function add_random_decor_to_room()
|
local function add_random_decor_to_room()
|
||||||
local decor_count = random(4) - 1
|
local decor_count = random(4) - 1
|
||||||
for i=1,decor_count do
|
for i=1,decor_count do
|
||||||
|
@ -222,9 +228,12 @@ local function add_exit(map, direction)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_level_exit(map)
|
local function add_level_exit(map)
|
||||||
x = random(14)
|
success = false
|
||||||
y = random(10)
|
while not success do
|
||||||
add_tile(map, x, y, repack(special.level_exit));
|
x = random(14)
|
||||||
|
y = random(10)
|
||||||
|
success = check_add_tile(map, x, y, special.level_exit);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function build_vert_center_coridoor(map, offset)
|
local function build_vert_center_coridoor(map, offset)
|
||||||
|
@ -235,10 +244,10 @@ local function build_vert_center_coridoor(map, offset)
|
||||||
add_tile(map, 9, offset+j, repack(wall.vertical));
|
add_tile(map, 9, offset+j, repack(wall.vertical));
|
||||||
end
|
end
|
||||||
if random(2) == 1 then
|
if random(2) == 1 then
|
||||||
check_add_decoration(map, 6, offset + 2, lightDecor.candle1)
|
add_decoration(map, 6, offset + 2, repack(lightDecor.candle1))
|
||||||
end
|
end
|
||||||
if random(2) == 1 then
|
if random(2) == 1 then
|
||||||
check_add_decoration(map, 9, offset + 2, lightDecor.candle1)
|
add_decoration(map, 9, offset + 2, repack(lightDecor.candle1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
34
src/main.c
34
src/main.c
|
@ -158,6 +158,7 @@ static void
|
||||||
startGame(void *unused)
|
startGame(void *unused)
|
||||||
{
|
{
|
||||||
UNUSED(unused);
|
UNUSED(unused);
|
||||||
|
cLevel = 1;
|
||||||
gGameState = PLAYING;
|
gGameState = PLAYING;
|
||||||
resetGame();
|
resetGame();
|
||||||
}
|
}
|
||||||
|
@ -228,9 +229,6 @@ initInGameMenu(void)
|
||||||
{ "QUIT", exitGame },
|
{ "QUIT", exitGame },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (inGameMenu)
|
|
||||||
menu_destroy(inGameMenu);
|
|
||||||
|
|
||||||
createMenu(&inGameMenu, menu_items, 3);
|
createMenu(&inGameMenu, menu_items, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,12 +258,12 @@ resetGame(void)
|
||||||
mainMenu = NULL;
|
mainMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
initInGameMenu();
|
if (!inGameMenu)
|
||||||
|
initInGameMenu();
|
||||||
|
|
||||||
if (gMap)
|
if (gMap)
|
||||||
map_destroy(gMap);
|
map_destroy(gMap);
|
||||||
|
|
||||||
cLevel = 1;
|
|
||||||
info("Building new map");
|
info("Building new map");
|
||||||
gMap = map_lua_generator_run(cLevel, gRenderer);
|
gMap = map_lua_generator_run(cLevel, gRenderer);
|
||||||
gPlayer->sprite->pos = (Position) {
|
gPlayer->sprite->pos = (Position) {
|
||||||
|
@ -296,8 +294,20 @@ loadMedia(void)
|
||||||
gPlayer = player_create(WARRIOR, gRenderer);
|
gPlayer = player_create(WARRIOR, gRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static bool
|
||||||
bool handle_events(void)
|
handle_main_events(SDL_Event *event)
|
||||||
|
{
|
||||||
|
if (gGameState == PLAYING || gGameState == IN_GAME_MENU) {
|
||||||
|
if (keyboard_press(SDLK_ESCAPE, event)) {
|
||||||
|
toggleInGameMenu(NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_events(void)
|
||||||
{
|
{
|
||||||
static SDL_Event event;
|
static SDL_Event event;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
|
@ -305,9 +315,13 @@ bool handle_events(void)
|
||||||
while (SDL_PollEvent(&event) != 0) {
|
while (SDL_PollEvent(&event) != 0) {
|
||||||
if (event.type == SDL_QUIT) {
|
if (event.type == SDL_QUIT) {
|
||||||
quit = true;
|
quit = true;
|
||||||
} else if (keyboard_press(SDLK_ESCAPE, &event)) {
|
continue;
|
||||||
toggleInGameMenu(NULL);
|
}
|
||||||
} else if (gGameState == PLAYING) {
|
|
||||||
|
if (handle_main_events(&event))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (gGameState == PLAYING) {
|
||||||
gPlayer->handle_event(gPlayer,
|
gPlayer->handle_event(gPlayer,
|
||||||
gRoomMatrix,
|
gRoomMatrix,
|
||||||
&event);
|
&event);
|
||||||
|
|
Loading…
Reference in New Issue