diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-06-20 09:32:33 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-06-20 09:32:33 +0000 |
commit | 28bb3033a5c5ca991fb04692608c2e828eb7ecbf (patch) | |
tree | f656f678dcaf0582af23048b2483f393e408d043 /apps | |
parent | 80ed0ce1dbb1a613fc15219c9544b397015d5504 (diff) | |
download | rockbox-28bb3033a5c5ca991fb04692608c2e828eb7ecbf.tar.gz rockbox-28bb3033a5c5ca991fb04692608c2e828eb7ecbf.zip |
Added level speeds. Cleaned up variables.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1119 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/tetris.c | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/apps/recorder/tetris.c b/apps/recorder/tetris.c index aa96a550a4..e22c4f00cc 100644 --- a/apps/recorder/tetris.c +++ b/apps/recorder/tetris.c | |||
@@ -38,23 +38,19 @@ | |||
38 | #define TETRIS_TITLE_XLOC 43 | 38 | #define TETRIS_TITLE_XLOC 43 |
39 | #define TETRIS_TITLE_YLOC 15 | 39 | #define TETRIS_TITLE_YLOC 15 |
40 | 40 | ||
41 | int start_x = 2; | 41 | static const int start_x = 2; |
42 | int start_y = 1; | 42 | static const int start_y = 1; |
43 | int max_x = 28; | 43 | static const int max_x = 28; |
44 | int max_y = 48; | 44 | static const int max_y = 48; |
45 | int current_x = 0; | 45 | static const short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200}; |
46 | int current_y = 0; | 46 | static const int blocks = 7; |
47 | int current_f = 0; | 47 | static const int block_frames[7] = {1,2,2,2,4,4,4}; |
48 | int current_b = 0; | 48 | |
49 | int level = 0; | 49 | static int current_x, current_y, current_f, current_b; |
50 | short lines = 0; | 50 | static int level, score; |
51 | int score = 0; | 51 | static int next_b, next_f; |
52 | int next_b = 0; | 52 | static short lines; |
53 | int next_f = 0; | 53 | static char virtual[LCD_WIDTH*LCD_HEIGHT]; |
54 | char virtual[LCD_WIDTH*LCD_HEIGHT]; | ||
55 | short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200}; | ||
56 | int blocks = 7; | ||
57 | int block_frames[7] = {1,2,2,2,4,4,4}; | ||
58 | 54 | ||
59 | /* | 55 | /* |
60 | block_data is built up the following way | 56 | block_data is built up the following way |
@@ -70,7 +66,7 @@ int block_frames[7] = {1,2,2,2,4,4,4}; | |||
70 | with block_data | 66 | with block_data |
71 | */ | 67 | */ |
72 | 68 | ||
73 | int block_data[7][4][2][4] = | 69 | static const char block_data[7][4][2][4] = |
74 | { | 70 | { |
75 | { | 71 | { |
76 | {{0,1,0,1},{0,0,1,1}} | 72 | {{0,1,0,1},{0,0,1,1}} |
@@ -332,11 +328,11 @@ void game_loop(void) | |||
332 | { | 328 | { |
333 | int b=0; | 329 | int b=0; |
334 | int count = 0; | 330 | int count = 0; |
335 | /* while(count*20 < level_speeds[level]) */ | 331 | while(count*300 < level_speeds[level]) |
336 | { | 332 | { |
337 | b = button_get(false); | 333 | b = button_get(false); |
338 | if ( b & BUTTON_OFF ) | 334 | if ( b & BUTTON_OFF ) |
339 | return; /* get out of here */ | 335 | return; /* get out of here */ |
340 | 336 | ||
341 | if ( b & BUTTON_LEFT ) { | 337 | if ( b & BUTTON_LEFT ) { |
342 | move_block(-2,0,0); | 338 | move_block(-2,0,0); |
@@ -353,19 +349,19 @@ void game_loop(void) | |||
353 | count++; | 349 | count++; |
354 | sleep(HZ/10); | 350 | sleep(HZ/10); |
355 | } | 351 | } |
356 | if(gameover()) { | 352 | if(gameover()) { |
357 | int w, h; | 353 | int w, h; |
358 | 354 | ||
359 | lcd_getfontsize(TETRIS_TITLE_FONT, &w, &h); | 355 | lcd_getfontsize(TETRIS_TITLE_FONT, &w, &h); |
360 | lcd_clearrect(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, | 356 | lcd_clearrect(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, |
361 | TETRIS_TITLE_XLOC+(w*sizeof(TETRIS_TITLE)), | 357 | TETRIS_TITLE_XLOC+(w*sizeof(TETRIS_TITLE)), |
362 | TETRIS_TITLE_YLOC-h); | 358 | TETRIS_TITLE_YLOC-h); |
363 | lcd_putsxy(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, "You lose!", | 359 | lcd_putsxy(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, "You lose!", |
364 | TETRIS_TITLE_FONT); | 360 | TETRIS_TITLE_FONT); |
365 | lcd_update(); | 361 | lcd_update(); |
366 | sleep(HZ); | 362 | sleep(HZ); |
367 | return; | 363 | return; |
368 | } | 364 | } |
369 | move_down(); | 365 | move_down(); |
370 | } | 366 | } |
371 | } | 367 | } |
@@ -373,10 +369,6 @@ void game_loop(void) | |||
373 | void init_tetris(void) | 369 | void init_tetris(void) |
374 | { | 370 | { |
375 | memset(&virtual, 0, sizeof(virtual)); | 371 | memset(&virtual, 0, sizeof(virtual)); |
376 | start_x = 2; | ||
377 | start_y = 1; | ||
378 | max_x = 28; | ||
379 | max_y = 48; | ||
380 | current_x = 0; | 372 | current_x = 0; |
381 | current_y = 0; | 373 | current_y = 0; |
382 | current_f = 0; | 374 | current_f = 0; |