meta: add title screen + random world generation
This commit is contained in:
parent
492ac60b4a
commit
27dd8b1d36
38
src/main.cpp
38
src/main.cpp
|
@ -4,6 +4,7 @@
|
|||
#include "game.h"
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/rtc.h>
|
||||
#include <gint/cpu.h>
|
||||
#include <libprof.h>
|
||||
#include <string.h>
|
||||
|
@ -111,10 +112,45 @@ static void renderGame(Game *game)
|
|||
}
|
||||
}
|
||||
|
||||
bool title_screen(void)
|
||||
{
|
||||
int selection = 0;
|
||||
|
||||
while(1) {
|
||||
renderClear();
|
||||
renderText(22, 5, "+---------+");
|
||||
renderText(22, 6, "|NOONCRAFT|");
|
||||
renderText(22, 7, "+---------+");
|
||||
|
||||
if(selection == 0)
|
||||
renderText(19, 10, "[PLAY DEMO WORLD]");
|
||||
else
|
||||
renderText(20, 10, "PLAY DEMO WORLD");
|
||||
|
||||
if(selection == 1)
|
||||
renderText(18, 12, "[PLAY RANDOM WORLD]");
|
||||
else
|
||||
renderText(19, 12, "PLAY RANDOM WORLD");
|
||||
|
||||
renderUpdate();
|
||||
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA;
|
||||
int key = getkey_opt(opt, NULL).key;
|
||||
if(key == KEY_EXE || key == KEY_SHIFT)
|
||||
return selection == 1;
|
||||
if(key == KEY_UP)
|
||||
selection = 0;
|
||||
if(key == KEY_DOWN)
|
||||
selection = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
prof_init();
|
||||
srand(0xc0ffee);
|
||||
|
||||
bool random = title_screen();
|
||||
srand(random ? rtc_ticks() : 0xc0ffee);
|
||||
|
||||
#ifdef NOONCRAFT_ENABLE_USB
|
||||
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
|
||||
|
|
Loading…
Reference in New Issue