finish da thing

The thing is now complete.
This commit is contained in:
KikooDX 2021-06-03 12:07:38 +02:00
parent 2cf29c38c0
commit 468ee6ce5b
8 changed files with 43 additions and 21 deletions

View File

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

After

Width:  |  Height:  |  Size: 549 B

View File

@ -1,7 +1,5 @@
#pragma once
#include "tiles.h"
#include <gint/defs/types.h>
#include <gint/display.h>
struct Grid {
int width;
@ -9,10 +7,14 @@ struct Grid {
uint8_t *data;
};
#include "player.h"
#include "tiles.h"
#include <gint/display.h>
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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;