inital commit
This commit is contained in:
23
source/debug.c
Normal file
23
source/debug.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "include.h"
|
||||
#include "debug.h"
|
||||
|
||||
void print_debug_menu() {
|
||||
int items_length = 2;
|
||||
char menu_items[10][32] = {
|
||||
"add money (500)",
|
||||
"back"
|
||||
};
|
||||
|
||||
while (true) {
|
||||
int selection = print_select_menu(menu_items, items_length);
|
||||
|
||||
switch (selection) {
|
||||
case 1:
|
||||
user_money = user_money + 500;
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
53
source/input.c
Normal file
53
source/input.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "include.h"
|
||||
|
||||
void waitForKey(char key) {
|
||||
while (true) {
|
||||
hidScanInput();
|
||||
u32 key_down = hidKeysDown();
|
||||
if (key_down & key) break;
|
||||
}
|
||||
}
|
||||
|
||||
int cursor_select(int items) {
|
||||
int cursor_position = 1;
|
||||
|
||||
printf("\x1b[%d;1H>", cursor_position);
|
||||
while (true) {
|
||||
hidScanInput();
|
||||
u32 key_down = hidKeysDown();
|
||||
|
||||
if (key_down & KEY_DDOWN) {
|
||||
printf("\x1b[%d;1H ", cursor_position);
|
||||
cursor_position = (cursor_position >= items) ? 1 : cursor_position + 1;
|
||||
printf("\x1b[%d;1H>", cursor_position);
|
||||
}
|
||||
if (key_down & KEY_DUP) {
|
||||
printf("\x1b[%d;1H ", cursor_position);
|
||||
cursor_position = (cursor_position <= 1) ? items : cursor_position - 1;
|
||||
printf("\x1b[%d;1H>", cursor_position);
|
||||
}
|
||||
if (key_down & KEY_B) {
|
||||
return 0;
|
||||
}
|
||||
if (key_down & KEY_A) {
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\x1b[10;16Hcursorpos: %d", cursor_position);
|
||||
}
|
||||
return cursor_position;
|
||||
}
|
||||
|
||||
void print_menu(char menu_items[10][32], int items_length) {
|
||||
for (int i = 0; i < items_length; i = i + 1) {
|
||||
printf("\x1b[%d;2H%s", i+1, menu_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int print_select_menu(char menu_items[10][32], int items_length) {
|
||||
consoleClear();
|
||||
print_menu(menu_items, items_length);
|
||||
int selection = cursor_select(items_length);
|
||||
return selection;
|
||||
}
|
||||
|
21
source/main.c
Normal file
21
source/main.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include "include.h"
|
||||
#include "main_menu.h"
|
||||
|
||||
int user_money = 0;
|
||||
|
||||
int held_pukekos = 0;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
srand(time(NULL));
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
|
||||
//printf("\x1b[15;13HPress the start button to start...");
|
||||
//waitForKey(KEY_START);
|
||||
consoleClear();
|
||||
|
||||
print_main_menu();
|
||||
|
||||
return 0;
|
||||
}
|
31
source/main_menu.c
Normal file
31
source/main_menu.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "main_menu.h"
|
||||
#include "include.h"
|
||||
#include "pukeko.h"
|
||||
#include "debug.h"
|
||||
|
||||
void print_main_menu() {
|
||||
int items_length = 3;
|
||||
char menu_items[10][32] = {
|
||||
"Catch pukekos",
|
||||
"Debugging",
|
||||
"Quit"
|
||||
};
|
||||
|
||||
while (true) {
|
||||
int selection = print_select_menu(menu_items, items_length);
|
||||
|
||||
switch (selection) {
|
||||
case 1:
|
||||
consoleClear();
|
||||
print_game_screen();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
print_debug_menu();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
44
source/pukeko.c
Normal file
44
source/pukeko.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "include.h"
|
||||
#include "pukeko.h"
|
||||
|
||||
void print_top_info() {
|
||||
printf("\x1b[1;1H(A) Catch Pukeko!!!");
|
||||
printf("\x1b[2;1H(Y) Sell Pukeko... :(");
|
||||
printf("\x1b[30;1H(B) Go back");
|
||||
}
|
||||
|
||||
void print_bottom_info() {
|
||||
consoleInit(GFX_BOTTOM, NULL);
|
||||
printf("\x1b[1;1HMoney: %d", user_money);
|
||||
|
||||
printf("\x1b[3;1HPukekos: %d", held_pukekos);
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
}
|
||||
|
||||
void catch_pukeko() {
|
||||
int random_number = rand() % 5 + 1;
|
||||
|
||||
printf("\x1b[1;1HDAMN!!! ");
|
||||
held_pukekos = held_pukekos + random_number;
|
||||
sleep(2);
|
||||
print_bottom_info();
|
||||
print_top_info();
|
||||
printf("\x1b[1;1H(A) Catch Pukeko!!!");
|
||||
}
|
||||
|
||||
void print_game_screen() {
|
||||
print_bottom_info();
|
||||
print_top_info();
|
||||
|
||||
while (true) {
|
||||
hidScanInput();
|
||||
u32 key_down = hidKeysDown();
|
||||
|
||||
if (key_down & KEY_A) {
|
||||
catch_pukeko();
|
||||
}
|
||||
if (key_down & KEY_B) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user