Permalink
Browse files

show highscores after 10sec of inactivity on menu

  • Loading branch information...
1 parent c33d7ce commit 54ec8493a90f6f196e01a068c135bcc10a75c3b4 @beerriot committed Feb 27, 2011
Showing with 12 additions and 7 deletions.
  1. +5 −4 blockgame.c
  2. +1 −1 include/bgmenu.h
  3. +6 −2 src/bgmenu.c
View
@@ -37,10 +37,11 @@ int main() {
sei(); //enable interrupts
while(1) {
- bgmenu_display(&game);
- bggame_play(&game);
- bggame_over(game.score);
- bghighscore_maybe(game.score);
+ if (bgmenu_display(&game)) {
+ bggame_play(&game);
+ bggame_over(game.score);
+ bghighscore_maybe(game.score);
+ }
bghighscore_screen();
}
View
@@ -5,5 +5,5 @@ void bgmenu_forb(int row, uint8_t focus);
void bgmenu_focus(int row);
void bgmenu_blur(int row);
void bgmenu_write_prompt(int row, int val);
-void bgmenu_display(struct game *game);
+uint8_t bgmenu_display(struct game *game);
#endif
View
@@ -37,8 +37,8 @@ void bgmenu_write_prompt(int row, int val) {
lcd_write_int16(val);
}
-void bgmenu_display(struct game *game) {
- int ready = 0, prompt = 0;
+uint8_t bgmenu_display(struct game *game) {
+ int ready = 0, prompt = 0, inactivity = 0;
uint8_t pressed_buttons;
int *field, min, max;
struct nkbuttons button_state;
@@ -66,6 +66,7 @@ void bgmenu_display(struct game *game) {
if (nktimer_animate()) {
pressed_buttons = nkbuttons_read(&button_state);
if(pressed_buttons) {
+ inactivity = 0;
if (pressed_buttons & B_SELECT && prompt == 3) {
ready = 1;
} else if (pressed_buttons & (B_UP | B_DOWN | B_SELECT)) {
@@ -97,8 +98,11 @@ void bgmenu_display(struct game *game) {
*field = *field-1;
bgmenu_write_prompt(prompt, *field);
}
+ } else if (++inactivity > 600) {
+ return 0; // leave menu for "screen saver" after 10sec
}
}
}
+ return 1;
}

0 comments on commit 54ec849

Please sign in to comment.