Add initial main loop logic

This commit is contained in:
hkz 2025-07-17 07:54:46 +02:00
commit 5fe7310d14
5 changed files with 38 additions and 10 deletions

View file

@ -83,7 +83,6 @@ game_state step_game(step_direction dir) {
column_step = 1;
row_step = GRID_SIDE;
break;
break;
case RIGHT:
start_offset = GRID_SIDE - 1;
column_step = -1;

View file

@ -6,7 +6,7 @@
#define GRID_SIDE 5
typedef enum {
UP,
UP = 0,
DOWN,
LEFT,
RIGHT

View file

@ -8,6 +8,7 @@
#include "mem_map.h"
#include "input.h"
#include "game_logic.h"
#include "game_graphics.h"
void __low_level_init(void);
@ -25,13 +26,38 @@ void __low_level_init(void) {
}
__task int main(void) {
key k;
game_state state;
while(1){ // Outer loop
reset_game();
draw_game_background();
while(1) { // Game loop
lfsr_update();
switch(read_kb()) {
case K_UP:
state = step_game(UP);
break;
case K_DOWN:
state = step_game(DOWN);
break;
case K_LEFT:
state = step_game(LEFT);
break;
case K_RIGHT:
state = step_game(RIGHT);
break;
default:
continue; // Do nothing, loop again
}
reset_game();
while(1){
lfsr_update();
k = read_kb();
// If we have finished, break out of this loop
if(state.done) break;
add_random_tile();
}
};
return 0;