dynamic memory allocation
This commit is contained in:
@@ -3,21 +3,26 @@
|
||||
#include "../../libpukeko/include/navigation.h"
|
||||
|
||||
void print_debug_menu() {
|
||||
int items_length = 2;
|
||||
char menu_items[10][32] = {
|
||||
"add money (500)",
|
||||
"back"
|
||||
};
|
||||
int items_count = 2;
|
||||
|
||||
MenuItem* menu = create_menu(items_count);
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
set_menu_item(menu, 0, "Add money (500)");
|
||||
set_menu_item(menu, 1, "Back");
|
||||
|
||||
while (true) {
|
||||
int selection = selector_render(menu_items, items_length);
|
||||
int selection = selector_render(menu, items_count);
|
||||
|
||||
switch (selection) {
|
||||
switch (selection)
|
||||
{
|
||||
case 1:
|
||||
user_money = user_money + 500;
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
destroy_menu(menu, items_count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -6,15 +6,18 @@
|
||||
#include "../../libpukeko/include/navigation.h"
|
||||
|
||||
void print_main_menu() {
|
||||
int items_length = 3;
|
||||
char menu_items[10][32] = {
|
||||
"Catch pukekos",
|
||||
"Debugging",
|
||||
"Quit"
|
||||
};
|
||||
int items_count = 3;
|
||||
|
||||
MenuItem* menu = create_menu(items_count);
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
set_menu_item(menu, 0, "Catch pukekos");
|
||||
set_menu_item(menu, 1, "Debugging");
|
||||
set_menu_item(menu, 2, "Quit");
|
||||
|
||||
while (true) {
|
||||
int selection = selector_render(menu_items, items_length);
|
||||
int selection = selector_render(menu, items_count);
|
||||
|
||||
switch (selection) {
|
||||
case 1:
|
||||
@@ -27,6 +30,7 @@ void print_main_menu() {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
destroy_menu(menu, items_count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user