diff --git a/CMakeLists.txt b/CMakeLists.txt index ff1e561..1a72321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # toolchain file and module path of the fxSDK cmake_minimum_required(VERSION 3.18) -project(ProtoDig C) +project(ProtoMine C) include(GenerateG3A) include(Fxconv) diff --git a/assets/icon-sel.png b/assets/icon-sel.png index 7137b50..33ff6be 100644 Binary files a/assets/icon-sel.png and b/assets/icon-sel.png differ diff --git a/assets/icon-uns.png b/assets/icon-uns.png index 3c99f62..4f99eea 100644 Binary files a/assets/icon-uns.png and b/assets/icon-uns.png differ diff --git a/assets/tileset.png b/assets/tileset.png index b312dbd..5ca01fa 100644 Binary files a/assets/tileset.png and b/assets/tileset.png differ diff --git a/include/grid.h b/include/grid.h index d316115..a50d8a1 100644 --- a/include/grid.h +++ b/include/grid.h @@ -1,7 +1,5 @@ #pragma once -#include "tiles.h" #include -#include struct Grid { int width; @@ -9,10 +7,14 @@ struct Grid { uint8_t *data; }; +#include "player.h" +#include "tiles.h" +#include + struct Grid grid_new(int width, int height); void grid_free(struct Grid); void grid_set(struct Grid *restrict, int x, int y, enum Tile); enum Tile grid_get(struct Grid, int x, int y); void grid_draw(struct Grid, int scr_x, int scr_y); -void grid_random_walker(struct Grid *restrict grid); -void grid_shop(struct Grid *restrict grid); +void grid_random_walker(struct Grid *restrict); +void grid_shop(struct Grid *restrict, struct Player *restrict); diff --git a/src/game/init.c b/src/game/init.c index 5f00af4..ec3be1e 100644 --- a/src/game/init.c +++ b/src/game/init.c @@ -10,8 +10,6 @@ game_init(void) grid_random_walker(&game.floor); game.player = player_init(0, game.floor.height / 2); game.rest = grid_new(25, 14); - game.player_rest = - player_init(game.rest.width / 2, game.rest.height - 1); return game; } diff --git a/src/grid/shop.c b/src/grid/shop.c index 2cfb7af..6f9c3c6 100644 --- a/src/grid/shop.c +++ b/src/grid/shop.c @@ -1,13 +1,16 @@ #include "grid.h" +#include "player.h" #include "tiles.h" void -grid_shop(struct Grid *restrict grid) +grid_shop(struct Grid *restrict grid, struct Player *restrict player) { const int x_middle = grid->width / 2; const int y_middle = grid->height / 2; grid_set(grid, x_middle - 2, y_middle, TILE_CONTRACTS_SPEED_UP); grid_set(grid, x_middle + 2, y_middle, TILE_CONTRACTS_SLOW_DOWN); - grid_set(grid, grid->width - 1, grid->height - 1, TILE_ZONE_TRANSITION); + grid_set(grid, grid->width - 3, grid->height - 3, TILE_ZONE_TRANSITION); + + *player = player_init(x_middle, y_middle + 2); } diff --git a/src/main.c b/src/main.c index 90c0eba..43d8810 100644 --- a/src/main.c +++ b/src/main.c @@ -14,15 +14,18 @@ int main(void) { struct Game game; + int state = 0; init_rand(); + do { + game = game_init(); - game = game_init(); + do { + state = main_loop(&game); + } while (!state); - while (!main_loop(&game)) { - } - - game_deinit(game); + game_deinit(game); + } while (state == -1); return 1; } @@ -31,7 +34,16 @@ static void init_rand(void) { dclear(C_BLACK); - dprint(0, 0, C_WHITE, "PRESS SHIFT"); + dprint(16, 16, C_WHITE, "Instructions:"); + dprint(16, 48, C_WHITE, "Move to the right to outrun scrolling."); + dprint(16, 64, C_WHITE, "Destroy gold (yellow blocs) for money."); + dprint(16, 80, C_WHITE, + "Rest rooms freeze time and propose two deals."); + dprint(16, 96, C_WHITE, "(NB: they impact scrolling speed and money)"); + dprint(16, 112, C_WHITE, "Have fun!"); + dprint(48, 128, C_WHITE, "-- KikooDX"); + dprint_opt(DWIDTH / 2, DHEIGHT - 16, C_WHITE, C_NONE, DTEXT_CENTER, + DTEXT_BOTTOM, "PRESS SHIFT"); dupdate(); unsigned int seed = 0; @@ -57,7 +69,7 @@ main_loop(struct Game *restrict game) case GameFloor: if (player_update(&game->player, &game->floor)) { game->state = GameRest; - grid_shop(&game->rest); + grid_shop(&game->rest, &game->player_rest); } scroll_x -= scroll_speed; scroll_speed += 0.0003; @@ -80,6 +92,11 @@ main_loop(struct Game *restrict game) } break; case GameDead: + if (keydown(KEY_SHIFT)) { + scroll_x = 99.0; + scroll_speed = 0.6; + return -1; + } default: break; } @@ -98,12 +115,14 @@ main_loop(struct Game *restrict game) game->state = GameDead; break; case GameDead: - dprint(0, 0, C_WHITE, "You died :("); - dprint(0, 16, C_WHITE, "Collected $%d", *game->player.cash); - dprint(0, 32, C_WHITE, "Survived %d feets", + dprint(16, 16 + 0, C_WHITE, "Scrolling killed you :("); + dprint(16, 16 + 16, C_WHITE, "Collected $%d", + *game->player.cash); + dprint(16, 16 + 16, C_WHITE, "Survived %d feets", -(int)(scroll_x / 4)); - dprint(0, 48, C_WHITE, "Thanks for playing :)"); - dprint(0, 64, C_WHITE, "(Press EXIT)"); + dprint(16, 16 + 48, C_WHITE, "Thanks for playing :)"); + dprint(16, 16 + 80, C_WHITE, + "Press SHIFT to play again or EXIT to quit"); break; default: break;