kolibrios/programs/games/2048/main.c
raandoom 3fdad8ab94 2048:
- fix flickering (canvas drawing added)
TODO:
 - optimize tile drawing: maybe separate canvas for every tile
 - game over screen
 - last game save / load
 - record save / load

git-svn-id: svn://kolibrios.org@5231 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-12-14 17:05:58 +00:00

56 lines
1.4 KiB
C

#include "game.h"
#define KEY_RELEASED 0x80
void main()
{
enable_scancode();
game_init();
for(;;)
{
int ev = __menuet__wait_for_event();
switch (ev)
{
case 1 : // EVENT_REDRAW:
game_redraw();
break;
case 2 : // EVENT_KEY:
{
ev = __menuet__getkey() & 0xFF;
switch (ev)
{
case ((K_Up & 0xFF) | KEY_RELEASED) : // key Up released
game_move_up();
clear_key_buffer();
break;
case ((K_Down & 0xFF) | KEY_RELEASED) : // key Down released
game_move_down();
clear_key_buffer();
break;
case ((K_Left & 0xFF) | KEY_RELEASED) : // key Left released
game_move_left();
clear_key_buffer();
break;
case ((K_Right & 0xFF) | KEY_RELEASED) : // key Right released
game_move_right();
clear_key_buffer();
break;
}
break;
}
case 3 : // EVENT_BUTTON
ev = __menuet__get_button_id();
switch (ev)
{
case NEW_GAME_BUTTON :
game_init();
break;
default : // close
game_exit();
return;
}
}
}
}