Introduces arcade mode
This commit is contained in:
parent
0f66b0f3d0
commit
f53703dd88
|
@ -57,6 +57,9 @@ local function generate_path ()
|
|||
if bossLevel or CURRENT_LEVEL == 1 then
|
||||
coverage = 5
|
||||
end
|
||||
if ARCADE_GAME then
|
||||
coverage = 40
|
||||
end
|
||||
|
||||
-- Create the first room
|
||||
map_matrix[cx][cy] = room_builder.create_empty_room()
|
||||
|
|
|
@ -91,6 +91,12 @@ typedef enum Direction_t {
|
|||
UP, DOWN, LEFT, RIGHT
|
||||
} Direction;
|
||||
|
||||
typedef enum GameMode {
|
||||
REGULAR,
|
||||
QUICK,
|
||||
ARCADE
|
||||
} GameMode;
|
||||
|
||||
#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_BUMPER(xindex, mode) CLIP16(xindex + (mode == 1 ? 16 : 0), 48)
|
||||
|
|
46
src/main.c
46
src/main.c
|
@ -164,6 +164,7 @@ static double renderScale = 1.0;
|
|||
static Turn currentTurn = PLAYER;
|
||||
static class_t playerClass = WARRIOR;
|
||||
static bool quickGame = false;
|
||||
static bool arcadeGame = false;
|
||||
static GameState gGameState;
|
||||
static SDL_Rect mainViewport;
|
||||
static SDL_Rect gameViewport;
|
||||
|
@ -331,7 +332,11 @@ initGame(void)
|
|||
static void
|
||||
startGame(void)
|
||||
{
|
||||
if (arcadeGame)
|
||||
cLevel = 19;
|
||||
else
|
||||
cLevel = 1;
|
||||
|
||||
gGameState = PLAYING;
|
||||
if (gPlayer)
|
||||
player_destroy(gPlayer);
|
||||
|
@ -347,6 +352,9 @@ startGame(void)
|
|||
if (!settings->howto_tooltip_shown)
|
||||
gGui->activeTooltip = howto_tooltip;
|
||||
settings->howto_tooltip_shown = true;
|
||||
|
||||
if (arcadeGame)
|
||||
player_set_level(gPlayer, 22);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -412,6 +420,13 @@ startQuickGame(void *unused)
|
|||
goToCharacterMenu(unused);
|
||||
}
|
||||
|
||||
static void
|
||||
startArcadeGame(void *unused)
|
||||
{
|
||||
arcadeGame = true;
|
||||
goToCharacterMenu(unused);
|
||||
}
|
||||
|
||||
static void
|
||||
goToMainMenu(void *unused)
|
||||
{
|
||||
|
@ -432,11 +447,24 @@ goToGameSelectMenu(void *unused)
|
|||
{
|
||||
UNUSED(unused);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -511,6 +539,8 @@ initMainMenu(void)
|
|||
mixer_play_music(MENU_MUSIC);
|
||||
creditsScreen = screen_create_credits(gRenderer);
|
||||
scoreScreen = screen_create_hiscore(gRenderer);
|
||||
quickGame = false;
|
||||
arcadeGame = false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -563,8 +593,14 @@ resetGame(void)
|
|||
|
||||
particle_engine_clear();
|
||||
|
||||
GameMode mode = REGULAR;
|
||||
if (quickGame)
|
||||
mode = QUICK;
|
||||
else if (arcadeGame)
|
||||
mode = ARCADE;
|
||||
|
||||
info("Building new map");
|
||||
gMap = map_lua_generator_run(cLevel, quickGame, gRenderer);
|
||||
gMap = map_lua_generator_run(cLevel, mode, gRenderer);
|
||||
|
||||
gPlayer->sprite->pos = (Position) {
|
||||
TILE_DIMENSION, TILE_DIMENSION };
|
||||
|
@ -1023,7 +1059,7 @@ run_game(void)
|
|||
gui_event_message("Well done!");
|
||||
end_game_details();
|
||||
#ifdef STEAM_BUILD
|
||||
if (cLevel >= 20)
|
||||
if (cLevel >= 20 && !arcadeGame)
|
||||
steam_set_achievement(BACK_TO_WORK);
|
||||
register_scores();
|
||||
#endif // STEAM_BUILD
|
||||
|
|
|
@ -129,8 +129,8 @@ l_map_set_current_room_modifier(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int l_map_set_current_room(lua_State *L)
|
||||
static int
|
||||
l_map_set_current_room(lua_State *L)
|
||||
{
|
||||
Map *map;
|
||||
unsigned int room_x, room_y;
|
||||
|
@ -144,8 +144,8 @@ int l_map_set_current_room(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int l_add_texture(lua_State *L)
|
||||
static int
|
||||
l_add_texture(lua_State *L)
|
||||
{
|
||||
Map *map;
|
||||
const char *path;
|
||||
|
@ -468,7 +468,7 @@ l_read_file(lua_State *L)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -526,9 +526,12 @@ generate_map(unsigned int level, const char *file, bool quickGame, SDL_Renderer
|
|||
lua_pushinteger(L, level);
|
||||
lua_setglobal(L, "CURRENT_LEVEL");
|
||||
|
||||
lua_pushboolean(L, quickGame);
|
||||
lua_pushboolean(L, gameMode == QUICK);
|
||||
lua_setglobal(L, "QUICK_MODE");
|
||||
|
||||
lua_pushboolean(L, gameMode == ARCADE);
|
||||
lua_setglobal(L, "ARCADE_MODE");
|
||||
|
||||
// Add custom searcher
|
||||
lua_getglobal(L, "package");
|
||||
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)
|
||||
{
|
||||
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";
|
||||
return generate_map(level, file, quickGame, renderer);
|
||||
return generate_map(level, file, gameMode, renderer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
#define MAP_LUA_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);
|
||||
|
||||
#endif // MAP_LUA_H_
|
||||
|
|
13
src/menu.c
13
src/menu.c
|
@ -38,7 +38,7 @@ typedef struct MenuItem {
|
|||
GuiButton *button;
|
||||
} MenuItem;
|
||||
|
||||
static void redraw_description(Menu *m, Camera *cam);
|
||||
static void redraw_description(Menu *m, SDL_Renderer *renderer);
|
||||
|
||||
Menu *
|
||||
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);
|
||||
linkedlist_append(&(*menu)->descriptions, (void*) menu_items[i].description);
|
||||
}
|
||||
|
||||
(*menu)->selected = 0;
|
||||
redraw_description(*menu, renderer);
|
||||
}
|
||||
|
||||
Menu *
|
||||
|
@ -141,7 +144,7 @@ menu_create_character_selector(void (*onCharacterSelect)(const char *), Camera *
|
|||
}
|
||||
|
||||
menu->selected = 0;
|
||||
redraw_description(menu, cam);
|
||||
redraw_description(menu, cam->renderer);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
@ -203,7 +206,7 @@ handle_mouse_motion(Menu *m, Input *input)
|
|||
}
|
||||
|
||||
static void
|
||||
redraw_description(Menu *m, Camera *cam)
|
||||
redraw_description(Menu *m, SDL_Renderer *renderer)
|
||||
{
|
||||
char *description = linkedlist_get(&m->descriptions, m->selected);
|
||||
if (!description || strlen(description) <= 1) {
|
||||
|
@ -216,7 +219,7 @@ redraw_description(Menu *m, Camera *cam)
|
|||
description,
|
||||
C_WHITE,
|
||||
C_BLACK,
|
||||
cam->renderer);
|
||||
renderer);
|
||||
m->menuDescription->dim = DIM(
|
||||
m->menuDescription->textures[0]->dim.width,
|
||||
m->menuDescription->textures[0]->dim.height);
|
||||
|
@ -248,7 +251,7 @@ menu_update(Menu *m, Input *input, Camera *cam)
|
|||
|
||||
if (lastSelected != m->selected) {
|
||||
lastSelected = m->selected;
|
||||
redraw_description(m, cam);
|
||||
redraw_description(m, cam->renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
20
src/player.c
20
src/player.c
|
@ -47,11 +47,9 @@
|
|||
#define ROGUE_STATS { 9, 9, 6, 9, 4, 2, 1, false, false }
|
||||
#define WARRIOR_STATS { 12, 12, 8, 9, 3, 1, 1, false, false }
|
||||
|
||||
void
|
||||
player_levelup(Player *player)
|
||||
static void
|
||||
levelup(Player *player)
|
||||
{
|
||||
mixer_play_effect(LEVEL_UP);
|
||||
|
||||
player->stats.lvl += 1;
|
||||
player->stats.maxhp += 9;
|
||||
player->stats.dmg += 5;
|
||||
|
@ -64,6 +62,20 @@ player_levelup(Player *player)
|
|||
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
|
||||
next_level_threshold(unsigned int current_level)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,9 @@ player_turn_over(Player*);
|
|||
void
|
||||
player_levelup(Player*);
|
||||
|
||||
void
|
||||
player_set_level(Player*, Uint8 level);
|
||||
|
||||
Uint32
|
||||
player_has_artifact(Player *, MagicalEffect);
|
||||
|
||||
|
|
Loading…
Reference in New Issue