summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-20 09:32:33 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-20 09:32:33 +0000
commit28bb3033a5c5ca991fb04692608c2e828eb7ecbf (patch)
treef656f678dcaf0582af23048b2483f393e408d043
parent80ed0ce1dbb1a613fc15219c9544b397015d5504 (diff)
downloadrockbox-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
-rw-r--r--apps/recorder/tetris.c66
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
41int start_x = 2; 41static const int start_x = 2;
42int start_y = 1; 42static const int start_y = 1;
43int max_x = 28; 43static const int max_x = 28;
44int max_y = 48; 44static const int max_y = 48;
45int current_x = 0; 45static const short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200};
46int current_y = 0; 46static const int blocks = 7;
47int current_f = 0; 47static const int block_frames[7] = {1,2,2,2,4,4,4};
48int current_b = 0; 48
49int level = 0; 49static int current_x, current_y, current_f, current_b;
50short lines = 0; 50static int level, score;
51int score = 0; 51static int next_b, next_f;
52int next_b = 0; 52static short lines;
53int next_f = 0; 53static char virtual[LCD_WIDTH*LCD_HEIGHT];
54char virtual[LCD_WIDTH*LCD_HEIGHT];
55short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200};
56int blocks = 7;
57int 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
73int block_data[7][4][2][4] = 69static 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)
373void init_tetris(void) 369void 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;