Introduces arcade mode

This commit is contained in:
Linus Probert 2018-10-26 18:37:50 +02:00
parent 0f66b0f3d0
commit f53703dd88
8 changed files with 92 additions and 25 deletions

View File

@ -57,6 +57,9 @@ local function generate_path ()
if bossLevel or CURRENT_LEVEL == 1 then if bossLevel or CURRENT_LEVEL == 1 then
coverage = 5 coverage = 5
end end
if ARCADE_GAME then
coverage = 40
end
-- Create the first room -- Create the first room
map_matrix[cx][cy] = room_builder.create_empty_room() map_matrix[cx][cy] = room_builder.create_empty_room()

View File

@ -91,6 +91,12 @@ typedef enum Direction_t {
UP, DOWN, LEFT, RIGHT UP, DOWN, LEFT, RIGHT
} Direction; } Direction;
typedef enum GameMode {
REGULAR,
QUICK,
ARCADE
} GameMode;
#define CONTROLLER_BTN(xindex, mode) CLIP16(xindex, mode == 1 ? 0 : 16) #define CONTROLLER_BTN(xindex, mode) CLIP16(xindex, mode == 1 ? 0 : 16)
#define CONTROLLER_TRIGGER(xindex, mode) CLIP16(xindex + (mode == 1 ? 16 : 0), 32) #define CONTROLLER_TRIGGER(xindex, mode) CLIP16(xindex + (mode == 1 ? 16 : 0), 32)
#define CONTROLLER_BUMPER(xindex, mode) CLIP16(xindex + (mode == 1 ? 16 : 0), 48) #define CONTROLLER_BUMPER(xindex, mode) CLIP16(xindex + (mode == 1 ? 16 : 0), 48)

View File

@ -164,6 +164,7 @@ static double renderScale = 1.0;
static Turn currentTurn = PLAYER; static Turn currentTurn = PLAYER;
static class_t playerClass = WARRIOR; static class_t playerClass = WARRIOR;
static bool quickGame = false; static bool quickGame = false;
static bool arcadeGame = false;
static GameState gGameState; static GameState gGameState;
static SDL_Rect mainViewport; static SDL_Rect mainViewport;
static SDL_Rect gameViewport; static SDL_Rect gameViewport;
@ -331,7 +332,11 @@ initGame(void)
static void static void
startGame(void) startGame(void)
{ {
cLevel = 1; if (arcadeGame)
cLevel = 19;
else
cLevel = 1;
gGameState = PLAYING; gGameState = PLAYING;
if (gPlayer) if (gPlayer)
player_destroy(gPlayer); player_destroy(gPlayer);
@ -347,6 +352,9 @@ startGame(void)
if (!settings->howto_tooltip_shown) if (!settings->howto_tooltip_shown)
gGui->activeTooltip = howto_tooltip; gGui->activeTooltip = howto_tooltip;
settings->howto_tooltip_shown = true; settings->howto_tooltip_shown = true;
if (arcadeGame)
player_set_level(gPlayer, 22);
} }
static void static void
@ -412,6 +420,13 @@ startQuickGame(void *unused)
goToCharacterMenu(unused); goToCharacterMenu(unused);
} }
static void
startArcadeGame(void *unused)
{
arcadeGame = true;
goToCharacterMenu(unused);
}
static void static void
goToMainMenu(void *unused) goToMainMenu(void *unused)
{ {
@ -432,11 +447,24 @@ goToGameSelectMenu(void *unused)
{ {
UNUSED(unused); UNUSED(unused);
static TEXT_MENU_ITEM menuItems[] = { static TEXT_MENU_ITEM menuItems[] = {
{ "STANDARD GAME", "", startRegularGame }, {
{ "QUICK GAME", "", startQuickGame }, "STANDARD GAME",
"Standard 20 level game, recommended for new players",
startRegularGame
},
{
"QUICK GAME",
"Shorter 12 level game, with more action earlier in the game",
startQuickGame
},
{
"ARCADE GAME",
"One big level with lots of action",
startArcadeGame
}
}; };
menu_create_text_menu(&gameSelectMenu, &menuItems[0], 2, gRenderer); menu_create_text_menu(&gameSelectMenu, &menuItems[0], 3, gRenderer);
gGameState = GAME_SELECT; gGameState = GAME_SELECT;
} }
@ -511,6 +539,8 @@ initMainMenu(void)
mixer_play_music(MENU_MUSIC); mixer_play_music(MENU_MUSIC);
creditsScreen = screen_create_credits(gRenderer); creditsScreen = screen_create_credits(gRenderer);
scoreScreen = screen_create_hiscore(gRenderer); scoreScreen = screen_create_hiscore(gRenderer);
quickGame = false;
arcadeGame = false;
} }
static void static void
@ -563,8 +593,14 @@ resetGame(void)
particle_engine_clear(); particle_engine_clear();
GameMode mode = REGULAR;
if (quickGame)
mode = QUICK;
else if (arcadeGame)
mode = ARCADE;
info("Building new map"); info("Building new map");
gMap = map_lua_generator_run(cLevel, quickGame, gRenderer); gMap = map_lua_generator_run(cLevel, mode, gRenderer);
gPlayer->sprite->pos = (Position) { gPlayer->sprite->pos = (Position) {
TILE_DIMENSION, TILE_DIMENSION }; TILE_DIMENSION, TILE_DIMENSION };
@ -1023,7 +1059,7 @@ run_game(void)
gui_event_message("Well done!"); gui_event_message("Well done!");
end_game_details(); end_game_details();
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
if (cLevel >= 20) if (cLevel >= 20 && !arcadeGame)
steam_set_achievement(BACK_TO_WORK); steam_set_achievement(BACK_TO_WORK);
register_scores(); register_scores();
#endif // STEAM_BUILD #endif // STEAM_BUILD

View File

@ -129,8 +129,8 @@ l_map_set_current_room_modifier(lua_State *L)
return 0; return 0;
} }
static static int
int l_map_set_current_room(lua_State *L) l_map_set_current_room(lua_State *L)
{ {
Map *map; Map *map;
unsigned int room_x, room_y; unsigned int room_x, room_y;
@ -144,8 +144,8 @@ int l_map_set_current_room(lua_State *L)
return 0; return 0;
} }
static static int
int l_add_texture(lua_State *L) l_add_texture(lua_State *L)
{ {
Map *map; Map *map;
const char *path; const char *path;
@ -468,7 +468,7 @@ l_read_file(lua_State *L)
} }
static Map* static Map*
generate_map(unsigned int level, const char *file, bool quickGame, SDL_Renderer *renderer) generate_map(unsigned int level, const char *file, GameMode gameMode, SDL_Renderer *renderer)
{ {
int status, result; int status, result;
@ -526,9 +526,12 @@ generate_map(unsigned int level, const char *file, bool quickGame, SDL_Renderer
lua_pushinteger(L, level); lua_pushinteger(L, level);
lua_setglobal(L, "CURRENT_LEVEL"); lua_setglobal(L, "CURRENT_LEVEL");
lua_pushboolean(L, quickGame); lua_pushboolean(L, gameMode == QUICK);
lua_setglobal(L, "QUICK_MODE"); lua_setglobal(L, "QUICK_MODE");
lua_pushboolean(L, gameMode == ARCADE);
lua_setglobal(L, "ARCADE_MODE");
// Add custom searcher // Add custom searcher
lua_getglobal(L, "package"); lua_getglobal(L, "package");
lua_getfield(L, -1, "searchers"); lua_getfield(L, -1, "searchers");
@ -557,13 +560,13 @@ generate_map(unsigned int level, const char *file, bool quickGame, SDL_Renderer
Map* map_lua_generator_single_room__run(unsigned int level, SDL_Renderer *renderer) Map* map_lua_generator_single_room__run(unsigned int level, SDL_Renderer *renderer)
{ {
char file[] = "menumapgen.lua"; char file[] = "menumapgen.lua";
return generate_map(level, file, false, renderer); return generate_map(level, file, REGULAR, renderer);
} }
Map* map_lua_generator_run(unsigned int level, bool quickGame, SDL_Renderer *renderer) Map* map_lua_generator_run(unsigned int level, GameMode gameMode, SDL_Renderer *renderer)
{ {
char file[] = "mapgen.lua"; char file[] = "mapgen.lua";
return generate_map(level, file, quickGame, renderer); return generate_map(level, file, gameMode, renderer);
} }

View File

@ -20,8 +20,9 @@
#define MAP_LUA_H_ #define MAP_LUA_H_
#include "map.h" #include "map.h"
#include "defines.h"
Map* map_lua_generator_run(unsigned int level, bool quickGame, SDL_Renderer *renderer); Map* map_lua_generator_run(unsigned int level, GameMode gameMode, SDL_Renderer *renderer);
Map* map_lua_generator_single_room__run(unsigned int level, SDL_Renderer *renderer); Map* map_lua_generator_single_room__run(unsigned int level, SDL_Renderer *renderer);
#endif // MAP_LUA_H_ #endif // MAP_LUA_H_

View File

@ -38,7 +38,7 @@ typedef struct MenuItem {
GuiButton *button; GuiButton *button;
} MenuItem; } MenuItem;
static void redraw_description(Menu *m, Camera *cam); static void redraw_description(Menu *m, SDL_Renderer *renderer);
Menu * Menu *
menu_create(void) menu_create(void)
@ -95,6 +95,9 @@ menu_create_text_menu(Menu **menu, TEXT_MENU_ITEM *menu_items, unsigned int size
menu_item_add(*menu, s1, s2, menu_items[i].callback); menu_item_add(*menu, s1, s2, menu_items[i].callback);
linkedlist_append(&(*menu)->descriptions, (void*) menu_items[i].description); linkedlist_append(&(*menu)->descriptions, (void*) menu_items[i].description);
} }
(*menu)->selected = 0;
redraw_description(*menu, renderer);
} }
Menu * Menu *
@ -141,7 +144,7 @@ menu_create_character_selector(void (*onCharacterSelect)(const char *), Camera *
} }
menu->selected = 0; menu->selected = 0;
redraw_description(menu, cam); redraw_description(menu, cam->renderer);
return menu; return menu;
} }
@ -203,7 +206,7 @@ handle_mouse_motion(Menu *m, Input *input)
} }
static void static void
redraw_description(Menu *m, Camera *cam) redraw_description(Menu *m, SDL_Renderer *renderer)
{ {
char *description = linkedlist_get(&m->descriptions, m->selected); char *description = linkedlist_get(&m->descriptions, m->selected);
if (!description || strlen(description) <= 1) { if (!description || strlen(description) <= 1) {
@ -216,7 +219,7 @@ redraw_description(Menu *m, Camera *cam)
description, description,
C_WHITE, C_WHITE,
C_BLACK, C_BLACK,
cam->renderer); renderer);
m->menuDescription->dim = DIM( m->menuDescription->dim = DIM(
m->menuDescription->textures[0]->dim.width, m->menuDescription->textures[0]->dim.width,
m->menuDescription->textures[0]->dim.height); m->menuDescription->textures[0]->dim.height);
@ -248,7 +251,7 @@ menu_update(Menu *m, Input *input, Camera *cam)
if (lastSelected != m->selected) { if (lastSelected != m->selected) {
lastSelected = m->selected; lastSelected = m->selected;
redraw_description(m, cam); redraw_description(m, cam->renderer);
} }
} }

View File

@ -47,11 +47,9 @@
#define ROGUE_STATS { 9, 9, 6, 9, 4, 2, 1, false, false } #define ROGUE_STATS { 9, 9, 6, 9, 4, 2, 1, false, false }
#define WARRIOR_STATS { 12, 12, 8, 9, 3, 1, 1, false, false } #define WARRIOR_STATS { 12, 12, 8, 9, 3, 1, 1, false, false }
void static void
player_levelup(Player *player) levelup(Player *player)
{ {
mixer_play_effect(LEVEL_UP);
player->stats.lvl += 1; player->stats.lvl += 1;
player->stats.maxhp += 9; player->stats.maxhp += 9;
player->stats.dmg += 5; player->stats.dmg += 5;
@ -64,6 +62,20 @@ player_levelup(Player *player)
player->stats.hp = player->stats.maxhp; player->stats.hp = player->stats.maxhp;
} }
void
player_levelup(Player *player)
{
mixer_play_effect(LEVEL_UP);
levelup(player);
}
void
player_set_level(Player *p, Uint8 level)
{
while (p->stats.lvl < level)
levelup(p);
}
static unsigned int static unsigned int
next_level_threshold(unsigned int current_level) next_level_threshold(unsigned int current_level)
{ {

View File

@ -119,6 +119,9 @@ player_turn_over(Player*);
void void
player_levelup(Player*); player_levelup(Player*);
void
player_set_level(Player*, Uint8 level);
Uint32 Uint32
player_has_artifact(Player *, MagicalEffect); player_has_artifact(Player *, MagicalEffect);