restructure

This commit is contained in:
yoruka
2025-05-10 13:52:29 +00:00
parent cdea49064b
commit b894f7fe4d
17 changed files with 133 additions and 275 deletions

27
program/Makefile Normal file
View File

@@ -0,0 +1,27 @@
include $(DEVKITARM)/3ds_rules
# Compiler flags
CFLAGS := -g -Wall -O2 $(ARCH) -D__3DS__
# Source files
SOURCES := src/debug/debug.c src/main_menu.c src/main.c src/pukeko.c
# Object files
OFILES := $(SOURCES:.c=.o)
# Build directory
BUILD := ../../build/program
.PHONY: all clean
all: $(BUILD)/pukeko.elf
$(BUILD)/pukeko.elf: $(OFILES) $(BUILD)/libpukeko.a
$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
$(BUILD)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(BUILD)/*.o $(BUILD)/pukeko.elf

6
program/include/debug.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef DEBUG_H
#define DEBUG_H
void print_debug_menu();
#endif // !DEBUG_H

View File

@@ -0,0 +1,6 @@
#ifndef MAIN_MENU_H
#define MAIN_MENU_H
void print_main_menu();
#endif //MAIN_MENU_H

7
program/include/pukeko.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef PUKEKO_H
#define PUKEKO_H
void print_game_screen();
#endif // !PUKEKO_H

View File

@@ -0,0 +1,7 @@
#ifndef PUKEKO_APP_H
#define PUKEKO_APP_H
extern int user_money;
extern int held_pukekos;
#endif // !PUKEKO_APP_H

24
program/src/debug/debug.c Normal file
View File

@@ -0,0 +1,24 @@
#include "pukeko_app.h"
#include "debug.h"
#include "../../libpukeko/include/navigation.h"
void print_debug_menu() {
int items_length = 2;
char menu_items[10][32] = {
"add money (500)",
"back"
};
while (true) {
int selection = selector_render(menu_items, items_length);
switch (selection) {
case 1:
user_money = user_money + 500;
break;
case 0:
case 2:
return;
}
}
}

23
program/src/main.c Normal file
View File

@@ -0,0 +1,23 @@
#include <3ds.h>
#include <stdlib.h>
#include <time.h>
#include "pukeko_app.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;
}

33
program/src/main_menu.c Normal file
View File

@@ -0,0 +1,33 @@
#include <3ds.h>
#include "main_menu.h"
#include "pukeko_app.h"
#include "pukeko.h"
#include "debug.h"
#include "../../libpukeko/include/navigation.h"
void print_main_menu() {
int items_length = 3;
char menu_items[10][32] = {
"Catch pukekos",
"Debugging",
"Quit"
};
while (true) {
int selection = selector_render(menu_items, items_length);
switch (selection) {
case 1:
consoleClear();
print_game_screen();
break;
case 2:
print_debug_menu();
break;
case 3:
return;
}
}
}

48
program/src/pukeko.c Normal file
View File

@@ -0,0 +1,48 @@
#include <3ds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "pukeko_app.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;
}
}
}