Skip to content

Commit 79c743f

Browse files
committed
help dialog added
1 parent b273dce commit 79c743f

File tree

4 files changed

+486
-8
lines changed

4 files changed

+486
-8
lines changed

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
build/*
2-
.idea/*
2+
.idea/*
3+
.cmake/*
4+
CMakeFiles/*
5+
Testing/*
6+
build.ninja
7+
cmake-build-debug/*
8+
cmake_install.cmake

kernel/game_be.c

+29-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
#include "../lib/data/game/player.h"
1212
#include "../lib/data/game/item.h"
1313
#include "../lib/data/data_menu_background.h"
14+
#include "../lib/data/help_dialog.h"
1415

1516
// ===== BACK-END =====
1617
const char directionKey[] = {'w', 'a', 's', 'd'};
1718
const int yOffset[] = {-1, 0, 1, 0};
1819
const int xOffset[] = {0, -1, 0, 1};
1920
uint16_t currentRadius = 40;
2021

21-
22+
void render_scene(const Maze *maze, const Asset *asset, const bool isFOVShown);
23+
void debug_pos(Position pos);
24+
void update_pos(Position *des, Direction dir);
25+
void handle_collision(Item *item, Maze *maze, Player *player);
26+
int cmp_pos(Position pos1, Position pos2);
27+
void debug_item(Item item);
2228

2329
void game_enter() {
2430
// init
@@ -58,7 +64,7 @@ void game_enter() {
5864

5965
// menu
6066
int menuPosX = 220, menuPosY = 250, yOffset = 50;
61-
char *opts[] = {"Start", "Continue", "How To Play?", "Exit"};
67+
char *opts[] = {"Start", "Choose Level", "How To Play?", "Exit"};
6268
int optSz = sizeof(opts) / sizeof(opts[0]);
6369
drawMenu(menuPosX, menuPosY, yOffset, opts, optSz);
6470

@@ -78,7 +84,9 @@ void game_enter() {
7884
break;
7985

8086
case 2: //help
87+
removeMenu(menuPosX, menuPosY, yOffset, opts, optSz);
8188
game_help();
89+
drawMenu(menuPosX, menuPosY, yOffset, opts, optSz);
8290
break;
8391

8492
case 3: //exit
@@ -228,6 +236,25 @@ void game_continue() {
228236

229237
void game_help() {
230238
uart_puts("Game Instruction...\n");
239+
240+
Asset dialog = {
241+
GAME_W / 2 - HELP_DIALOG_WIDTH / 2,
242+
GAME_H / 2 - HELP_DIALOG_HEIGHT / 2,
243+
HELP_DIALOG_WIDTH,
244+
HELP_DIALOG_HEIGHT,
245+
bitmap_help_dialog
246+
};
247+
248+
drawAsset(&dialog);
249+
250+
char c = 0;
251+
while ((c = uart_getc()) != '\n') {}
252+
253+
for (int i = GAME_W / 2 - HELP_DIALOG_WIDTH / 2, posX = 0; posX < HELP_DIALOG_WIDTH; i++, posX++) {
254+
for (int j = GAME_H / 2 - HELP_DIALOG_HEIGHT / 2, posY = 0; posY < HELP_DIALOG_HEIGHT; j++, posY++) {
255+
framebf_drawPixel(i, j, bitmap_menu_background[i + j * MENU_BACKGROUND_SIZE]);
256+
}
257+
}
231258
}
232259

233260

kernel/game_fe.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../lib/data/game/maze.h"
77
#include "../lib/data/data_font.h"
88
#include "../lib/data/game/player_movement.h"
9+
#include "../lib/font.h"
910

1011
#define STEP_AMOUNT 3
1112
#define RECT_BORDER 10
@@ -37,21 +38,21 @@ void removeMenu(int posX, int posY, int spacing, char *opts[], int optSz) {
3738

3839
int getMenuOpt(int markPosX, int markPosY, int yOffset, int optSz, const unsigned int foregnd, const unsigned int backgnd) {
3940
int actionIdx = 0;
40-
font_drawChar(markPosX, markPosY, '>', foregnd, 2);
41+
font_drawChar(markPosX, markPosY, '>', foregnd, 2, 1);
4142

4243
while (1) {
4344
char c = uart_getc();
4445
uart_sendc(c);
4546
uart_sendc('\n');
4647
if (c == 'w' || c == 'a') {
47-
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', backgnd, 2);
48+
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', backgnd, 2, 1);
4849
actionIdx = (actionIdx - 1) % optSz;
4950
if (actionIdx < 0) actionIdx += optSz;
50-
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', foregnd, 2);
51+
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', foregnd, 2, 1);
5152
} else if (c == 's' || c == 'd') {
52-
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', backgnd, 2);
53+
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', backgnd, 2, 1);
5354
actionIdx = (actionIdx + 1) % optSz;
54-
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', foregnd, 2);
55+
font_drawChar(markPosX, markPosY + actionIdx * yOffset, '>', foregnd, 2, 1);
5556
} else if (c == '\n') {
5657
break;
5758
}

0 commit comments

Comments
 (0)