Index: apps/plugins/brickmania.c =================================================================== --- apps/plugins/brickmania.c (revision 23000) +++ apps/plugins/brickmania.c (working copy) @@ -45,7 +45,6 @@ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ (CONFIG_KEYPAD == IRIVER_H300_PAD) -#define CONTINUE_TEXT "Press NAVI To Continue" #define QUIT BUTTON_OFF #define LEFT BUTTON_LEFT #define RIGHT BUTTON_RIGHT @@ -55,7 +54,6 @@ #define RC_QUIT BUTTON_RC_STOP #elif CONFIG_KEYPAD == ONDIO_PAD -#define CONTINUE_TEXT "MENU To Continue" #define QUIT BUTTON_OFF #define LEFT BUTTON_LEFT #define RIGHT BUTTON_RIGHT @@ -167,7 +165,6 @@ #define DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == IAUDIO_M3_PAD -#define CONTINUE_TEXT "PLAY To Continue" #define QUIT BUTTON_RC_REC #define LEFT BUTTON_RC_REW #define RIGHT BUTTON_RC_FF @@ -237,13 +234,6 @@ #endif #endif -/* Continue text is used as a string later when the game is paused. This allows - * targets to specify their own text if needed. - */ -#if !defined(CONTINUE_TEXT) -#define CONTINUE_TEXT "Press SELECT To Continue" -#endif - #ifndef SCROLL_FWD /* targets without scroll wheel*/ #define SCROLL_FWD(x) (0) #define SCROLL_BACK(x) (0) @@ -338,9 +328,18 @@ /*calculate paddle y-position */ #define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1) -int levels_num = 29; +int levels_num = 40; /*change the number after the = sign to however many levels there are, i.e. how many arrays there are total */ -static unsigned char levels[29][8][10] = +static unsigned char levels[40][8][10] = { /*change the first number in [ ] to however many levels there are (should match the one above */ + + /*You can set up new levels with the level editor ( http://plugbox.rockbox-lounge.de/brickmania.htm ). + *With 0x1, it refers to the first brick in the bitmap, 0x2 would refer to the second, ect., 0x0 leaves a empty space. If you add a 2 + *before the 2nd number, it will take two hits to break, and 3 hits if you add a 3. That is 0x24, will result with the fourth + *brick being displayed and having take 2 hits to break. You could do the same with the 3, just replace the 2 with a 3 for it to + *take three hits to break it apart. + */ + + { { /* level1 */ {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1}, @@ -622,14 +621,124 @@ {0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4}, {0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1} }, + { /* level 29 UK Flag by Seth Opgenorth */ + {0x32,0x0,0x3,0x3,0x2,0x2,0x3,0x3,0x0,0x32}, + {0x0,0x2,0x0,0x3,0x32,0x22,0x33,0x0,0x32,0x0}, + {0x33,0x0,0x22,0x0,0x2,0x2,0x0,0x2,0x0,0x33}, + {0x22,0x32,0x2,0x2,0x2,0x2,0x2,0x2,0x22,0x2}, + {0x3,0x0,0x0,0x32,0x22,0x2,0x2,0x0,0x0,0x3}, + {0x23,0x0,0x32,0x0,0x32,0x2,0x0,0x2,0x0,0x3}, + {0x0,0x2,0x0,0x3,0x2,0x2,0x3,0x0,0x22,0x0}, + {0x32,0x0,0x3,0x23,0x2,0x2,0x23,0x33,0x0,0x32} + }, + { /* level 30 Win-Logo by Seth Opgenorth */ + {0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x0}, + {0x0,0x0,0x32,0x2,0x2,0x25,0x0,0x5,0x0,0x0}, + {0x0,0x0,0x2,0x22,0x2,0x5,0x5,0x35,0x0,0x0}, + {0x0,0x0,0x2,0x1,0x2,0x5,0x5,0x25,0x0,0x0}, + {0x0,0x0,0x21,0x1,0x1,0x36,0x7,0x26,0x0,0x0}, + {0x0,0x0,0x1,0x1,0x1,0x6,0x6,0x6,0x0,0x0}, + {0x0,0x0,0x21,0x0,0x21,0x6,0x6,0x26,0x0,0x0}, + {0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0} + }, + { /* level 31 Color wave/V by Seth Opgenorth */ + {0x25,0x34,0x2,0x31,0x33,0x23,0x1,0x2,0x34,0x5}, + {0x3,0x5,0x24,0x2,0x1,0x1,0x2,0x4,0x5,0x3}, + {0x1,0x3,0x5,0x4,0x2,0x2,0x4,0x5,0x3,0x1}, + {0x2,0x1,0x33,0x35,0x4,0x4,0x5,0x33,0x1,0x22}, + {0x31,0x22,0x1,0x3,0x5,0x25,0x3,0x1,0x2,0x31}, + {0x3,0x1,0x2,0x1,0x3,0x3,0x1,0x2,0x21,0x3}, + {0x5,0x23,0x1,0x32,0x1,0x1,0x2,0x1,0x3,0x5}, + {0x4,0x35,0x3,0x1,0x2,0x22,0x31,0x3,0x5,0x4} + }, + { /* level 32 Sweedish Flag by Seth Opgenorth */ + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}, + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}, + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}, + {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}, + {0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36}, + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}, + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}, + {0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3} + }, + { /* level 33 Color Pyramid by Seth Opgenorth */ + {0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0}, + {0x0,0x0,0x0,0x4,0x24,0x4,0x24,0x0,0x0,0x0}, + {0x0,0x0,0x23,0x3,0x3,0x3,0x23,0x3,0x0,0x0}, + {0x0,0x0,0x25,0x5,0x25,0x35,0x5,0x35,0x0,0x0}, + {0x0,0x36,0x6,0x6,0x6,0x6,0x26,0x6,0x6,0x0}, + {0x0,0x7,0x7,0x7,0x7,0x25,0x27,0x7,0x27,0x0}, + {0x2,0x2,0x22,0x2,0x2,0x2,0x22,0x2,0x2,0x2}, + {0x21,0x1,0x1,0x31,0x1,0x21,0x1,0x1,0x31,0x1} + }, + { /* level 34 Rhombus by Seth Opgenorth */ + {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0}, + {0x0,0x0,0x0,0x3,0x32,0x22,0x23,0x0,0x0,0x0}, + {0x0,0x0,0x3,0x2,0x24,0x4,0x2,0x23,0x0,0x0}, + {0x26,0x3,0x2,0x4,0x5,0x5,0x4,0x22,0x3,0x6}, + {0x36,0x3,0x2,0x34,0x5,0x5,0x4,0x2,0x3,0x36}, + {0x0,0x0,0x3,0x2,0x4,0x34,0x2,0x23,0x0,0x0}, + {0x0,0x0,0x0,0x23,0x2,0x2,0x3,0x0,0x0,0x0}, + {0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0} + }, + { /* level 35 PacMan Ghost by Seth Opgenorth */ + {0x0,0x0,0x0,0x0,0x2,0x32,0x2,0x0,0x0,0x0}, + {0x0,0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x0,0x0}, + {0x0,0x0,0x2,0x24,0x4,0x2,0x4,0x4,0x32,0x0}, + {0x0,0x0,0x2,0x24,0x0,0x22,0x24,0x0,0x22,0x0}, + {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}, + {0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}, + {0x0,0x0,0x2,0x32,0x2,0x2,0x22,0x2,0x32,0x0}, + {0x0,0x0,0x0,0x22,0x0,0x32,0x0,0x22,0x0,0x0} + }, + { /* level 36 Star by Seth Opgenorth */ + {0x3,0x4,0x3,0x4,0x6,0x24,0x3,0x24,0x3,0x0}, + {0x24,0x0,0x0,0x6,0x6,0x6,0x0,0x0,0x4,0x0}, + {0x3,0x26,0x6,0x2,0x6,0x2,0x6,0x26,0x23,0x0}, + {0x4,0x0,0x6,0x6,0x36,0x6,0x6,0x0,0x4,0x0}, + {0x3,0x0,0x0,0x26,0x6,0x26,0x0,0x0,0x33,0x0}, + {0x34,0x0,0x6,0x6,0x0,0x6,0x6,0x0,0x4,0x0}, + {0x3,0x26,0x6,0x0,0x0,0x0,0x6,0x6,0x3,0x0}, + {0x4,0x3,0x4,0x23,0x24,0x3,0x4,0x33,0x4,0x0} + }, + { /* level 37 It's 8-Bit by Seth Opgenorth */ + {0x26,0x26,0x6,0x6,0x5,0x6,0x26,0x6,0x26,0x6}, + {0x2,0x2,0x22,0x3,0x3,0x0,0x0,0x0,0x4,0x0}, + {0x2,0x0,0x2,0x33,0x3,0x3,0x5,0x0,0x24,0x0}, + {0x32,0x2,0x2,0x33,0x0,0x23,0x0,0x4,0x4,0x4}, + {0x2,0x22,0x2,0x3,0x3,0x0,0x5,0x4,0x4,0x24}, + {0x2,0x0,0x2,0x23,0x0,0x3,0x25,0x0,0x4,0x0}, + {0x22,0x2,0x2,0x3,0x23,0x0,0x5,0x0,0x4,0x0}, + {0x6,0x26,0x6,0x36,0x6,0x36,0x6,0x6,0x6,0x6} + }, + { /* level 38 Linux by Seth Opgenorth */ + {0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, + {0x7,0x0,0x0,0x0,0x33,0x0,0x23,0x0,0x0,0x0}, + {0x7,0x32,0x0,0x0,0x3,0x0,0x23,0x6,0x0,0x6}, + {0x37,0x0,0x0,0x0,0x23,0x0,0x3,0x6,0x0,0x26}, + {0x7,0x22,0x24,0x0,0x3,0x33,0x3,0x0,0x26,0x0}, + {0x37,0x22,0x24,0x24,0x4,0x0,0x0,0x0,0x26,0x0}, + {0x7,0x2,0x4,0x0,0x4,0x0,0x0,0x6,0x0,0x26}, + {0x7,0x27,0x4,0x0,0x34,0x0,0x0,0x6,0x0,0x26} + }, + { /* level 39 Colorful Squares by Seth Opgenorth*/ + {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0}, + {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0}, + {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0}, + {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0}, + {0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0}, + {0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0}, + {0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0}, + {0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0} + }, { /* TheEnd */ {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, - {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0}, - {0x22,0x0,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0}, - {0x22,0x22,0x26,0x26,0x0,0x26,0x24,0x0,0x24,0x0}, - {0x22,0x22,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0}, - {0x22,0x0,0x26,0x0,0x26,0x26,0x24,0x0,0x24,0x0}, - {0x22,0x22,0x26,0x0,0x0,0x26,0x24,0x24,0x0,0x0}, + {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0}, + {0x32,0x0,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0}, + {0x32,0x32,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0}, + {0x32,0x32,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0}, + {0x32,0x0,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0}, + {0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0}, {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} } }; @@ -814,7 +923,7 @@ return 0; } -static void brickmania_init_game(bool new_game) +static void brickmania_init_game(int new_game) { int i,j; @@ -838,7 +947,7 @@ flip_sides = false; num_count = 10; - if (new_game) { + if (new_game==1) { brick_on_board=0; /* add one life per achieved level */ if (difficulty==EASY && life<2) { @@ -856,7 +965,7 @@ for(j=0;j<=9;j++) { int bnum = i*10+j; brick[bnum].poweruse = false; - if (new_game) { + if (new_game==1) { brick[bnum].power=rb->rand()%25; /* +8 make the game with less powerups */ @@ -942,15 +1051,13 @@ int count=0; int sw, w; - while (!done) - { - if (count == 0) - count = *rb->current_tick + HZ*secs; - if ( (*rb->current_tick >= count) && (vscore == score) ) - done = true; - - if(vscore != score) - { + while (!done) { + if (vscore == score) { + if (count==0) + count=*rb->current_tick+HZ*secs; + if (*rb->current_tick>=count) + done=true; + } else { if (vscorescore) @@ -1067,11 +1174,6 @@ { "Normal", -1 }, }; -#ifdef HAVE_TOUCHSCREEN - /* Entering Menu, set the touchscreen to the global setting */ - rb->touchscreen_set_mode(rb->global_settings->touch_mode); -#endif - MENUITEM_STRINGLIST(main_menu, "Brickmania Menu", brickmania_menu_cb, "Resume Game", "Start New Game", "Difficulty", "Help", "High Scores", @@ -1092,7 +1194,7 @@ vscore=0; life=2; level=0; - brickmania_init_game(true); + brickmania_init_game(1); return 0; case 2: rb->set_option("Difficulty", &difficulty, INT, @@ -1123,9 +1225,6 @@ break; } } -#ifdef HAVE_TOUCHSCREEN - rb->touchscreen_set_mode(TOUCHSCREEN_POINT); -#endif } /* Find an unused fire position */ @@ -1141,9 +1240,6 @@ void brick_hit(int brick_number) { - if(!brick[brick_number].used) - return; - /* if this is a crackable brick hits starts as * greater than 0. */ @@ -1153,9 +1249,9 @@ score+=2; } else { - brick[brick_number].used=false; + brick[brick_number].used=0; /* Was there a powerup on the brick? */ - if (brick[brick_number].power<10) { + if (brick[brick_number].power!=10) { /* Activate the powerup */ brick[brick_number].poweruse = true; } @@ -1166,44 +1262,43 @@ static int brickmania_game_loop(void) { - int j,i,k; + int j,i,k,bricky,brickx; int sw; char s[30]; int sec_count=0; int end; - /* pad_line used for powerup/ball checks */ - line pad_line; + /* these lines are used to describe the brick */ + line bot_brick, top_brick, left_brick, rght_brick, pad_line; /* This is used for various lines that are checked (ball and powerup) */ line misc_line; /* This stores the point that the two lines intersected in a test */ point pt_hit; - if (brickmania_menu()) { + if (brickmania_menu()!=0) { return 1; } resume = false; resume_file = false; - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); - rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_clear_display(); -#endif while(true) { /* Convert CYCLETIME (in ms) to HZ */ end = *rb->current_tick + (CYCLETIME * HZ) / 1000; if (life >= 0) { +#ifdef HAVE_LCD_COLOR + rb->lcd_set_background(LCD_BLACK); + rb->lcd_set_drawmode(DRMODE_SOLID); rb->lcd_clear_display(); + rb->lcd_set_background(LCD_BLACK); + rb->lcd_set_foreground(LCD_WHITE); +#else + rb->lcd_clear_display(); +#endif - if (flip_sides) - { - if (*rb->current_tick>=sec_count) - { + if (flip_sides) { + if (*rb->current_tick>=sec_count) { sec_count=*rb->current_tick+HZ; if (num_count!=0) num_count--; @@ -1238,9 +1333,17 @@ rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); /* continue game */ - if (game_state == ST_PAUSE) + if (game_state==ST_PAUSE) { - rb->snprintf(s, sizeof(s), CONTINUE_TEXT); +#if CONFIG_KEYPAD == ONDIO_PAD + rb->snprintf(s, sizeof(s), "MENU To Continue"); +#elif CONFIG_KEYPAD == IRIVER_H300_PAD + rb->snprintf(s, sizeof(s), "Press NAVI To Continue"); +#elif CONFIG_KEYPAD == IAUDIO_M3_PAD + rb->snprintf(s, sizeof(s), "PLAY To Continue"); +#else + rb->snprintf(s, sizeof(s), "Press SELECT To Continue"); +#endif rb->lcd_getstringsize(s, &sw, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_NAVI), s); @@ -1256,7 +1359,7 @@ brick_on_board--; /* if the pad is fire */ - for(i=0; i<30; i++) + for(i=0;i<30;i++) { /* If the projectile is active (>0 inactive) */ if (fire[i].top >= 0) @@ -1268,34 +1371,34 @@ INT3(fire[i].top + FIRE_LENGTH)); } } - - /* Setup the pad line-later used in intersection test */ - pad_line.p1.x = pad_pos_x; - pad_line.p1.y = PAD_POS_Y; - - pad_line.p2.x = pad_pos_x + pad_width; - pad_line.p2.y = PAD_POS_Y; /* handle all of the bricks */ - for (i=0; i<=7; i++) + for (i=0;i<=7;i++) { - for (j=0; j<=9 ;j++) + for (j=0;j<=9;j++) { - int brickx; + int brick_width = BRICK_WIDTH; + int bnum = i*10+j; + brickx = LEFTMARGIN + j*BRICK_WIDTH; - /* This brick is not really a brick, it is a powerup if - * poweruse is set. Perform appropriate powerup checks. - */ - if(brick[bnum].poweruse) + /* Setup the pad line - later used for intersection tests*/ + pad_line.p1.x = pad_pos_x; + pad_line.p1.y = PAD_POS_Y + PAD_HEIGHT; + + pad_line.p2.x = pad_pos_x + pad_width; + pad_line.p2.y = PAD_POS_Y + PAD_HEIGHT; + + /* This is the only place the that powertop is updated */ + if (brick[bnum].poweruse && brick[bnum].power<9) { - brickx = LEFTMARGIN + j*BRICK_WIDTH + - (BRICK_WIDTH - POWERUP_WIDTH) / 2; - - /* Update powertop if the game is not paused */ if (game_state!=ST_PAUSE) brick[bnum].powertop+=SPEED_POWER; - + + brick_width = POWERUP_WIDTH; + brickx = LEFTMARGIN + j*BRICK_WIDTH + + ((BRICK_WIDTH - POWERUP_WIDTH) >> 1); + /* Draw the powerup */ rb->lcd_bitmap_part(brickmania_powerups,0, INT3(POWERUP_HEIGHT)*brick[bnum].power, @@ -1306,192 +1409,182 @@ INT3(brick[bnum].powertop), INT3(POWERUP_WIDTH), INT3(POWERUP_HEIGHT) ); - - /* Use misc_line to check if the center of the powerup - * hit the paddle. - */ - misc_line.p1.x = brickx + (POWERUP_WIDTH >> 1); - misc_line.p1.y = brick[bnum].powertop + POWERUP_HEIGHT; - - misc_line.p2.x = brickx + (POWERUP_WIDTH >> 1); - misc_line.p2.y = SPEED_POWER + brick[bnum].powertop + - POWERUP_HEIGHT; + } - /* Check if the powerup will hit the paddle */ - if ( check_lines(&misc_line, &pad_line, &pt_hit) ) - { - switch(brick[bnum].power) { - case 0: /* Extra Life */ - life++; - score += 50; - break; - case 1: /* Loose a life */ - life--; - if (life>=0) - { - brickmania_init_game(false); - brickmania_sleep(2); - } - break; - case 2: /* Make the paddle sticky */ - score += 34; - pad_type = STICKY; - break; - case 3: /* Give the paddle shooter */ - score += 47; - pad_type = SHOOTER; - for(k=0;k> 1); + misc_line.p1.y = brick[bnum].powertop + POWERUP_HEIGHT; + + misc_line.p2.x = brickx + (brick_width >> 1); + misc_line.p2.y = SPEED_POWER + brick[bnum].powertop + + POWERUP_HEIGHT; - pad_pos_x += (pad_width-PAD_WIDTH)/2; + /* Check if the powerup will hit the paddle */ + if (brick[bnum].poweruse && /* Is the powerup active? */ + check_lines(&misc_line, &pad_line, &pt_hit) ) + { + switch(brick[bnum].power) { + case 0: /* Extra Life */ + life++; + score += 50; + break; + case 1: /* Loose a life */ + life--; + if (life>=0) + { + brickmania_init_game(0); + brickmania_sleep(2); + } + break; + case 2: /* Make the paddle sticky */ + score += 34; + pad_type = STICKY; + break; + case 3: /* Give the paddle shooter */ + score += 47; + pad_type = SHOOTER; + for(k=0;kcurrent_tick+HZ; + num_count = 10; + flip_sides = true; + break; + case 6: /* Extra Ball */ + score += 23; + if(used_ballsrand()%2 == 0 ? + -SPEED_4Q_X : SPEED_4Q_X; + ball[used_balls].speedy= SPEED_4Q_Y; + + /* Ball is not glued */ + ball[used_balls].glue= false; + used_balls++; + } + break; + case 7: /* Long paddle */ + score+=23; + if (pad_width==PAD_WIDTH) + { + pad_width = LONG_PAD_WIDTH; + pad_pos_x -= (LONG_PAD_WIDTH -PAD_WIDTH)/2; + } + else if (pad_width==SHORT_PAD_WIDTH) + { pad_width = PAD_WIDTH; - break; - case 5: /* Flip the paddle */ - score += 23; - sec_count = *rb->current_tick+HZ; - num_count = 10; - flip_sides = true; - break; - case 6: /* Extra Ball */ - score += 23; - if(used_ballsrand()%2 == 0) - ball[used_balls].speedx=-SPEED_4Q_X; - else - ball[used_balls].speedx= SPEED_4Q_X; - - ball[used_balls].speedy= SPEED_4Q_Y; - - /* Ball is not glued */ - ball[used_balls].glue= false; - used_balls++; - } - break; - case 7: /* Long paddle */ - score+=23; - if (pad_width==PAD_WIDTH) - { - pad_width = LONG_PAD_WIDTH; - pad_pos_x -= (LONG_PAD_WIDTH - - PAD_WIDTH)/2; - } - else if (pad_width==SHORT_PAD_WIDTH) - { - pad_width = PAD_WIDTH; - pad_pos_x-=(PAD_WIDTH- - SHORT_PAD_WIDTH)/2; - } - - if (pad_pos_x < 0) - pad_pos_x = 0; - else if(pad_pos_x + pad_width > - GAMESCREEN_WIDTH) - pad_pos_x = GAMESCREEN_WIDTH-pad_width; - break; - case 8: /* Short Paddle */ - if (pad_width==PAD_WIDTH) - { - pad_width=SHORT_PAD_WIDTH; - pad_pos_x+=(PAD_WIDTH- - SHORT_PAD_WIDTH)/2; - } - else if (pad_width==LONG_PAD_WIDTH) - { - pad_width=PAD_WIDTH; - pad_pos_x+=(LONG_PAD_WIDTH-PAD_WIDTH)/2; - } - break; - } - /* Disable the powerup (it was picked up) */ - brick[bnum].poweruse = false; + pad_pos_x-=(PAD_WIDTH-SHORT_PAD_WIDTH)/2; + } + + if (pad_pos_x < 0) + pad_pos_x = 0; + else if(pad_pos_x+pad_width > GAMESCREEN_WIDTH) + pad_pos_x = GAMESCREEN_WIDTH-pad_width; + break; + case 8: /* Short Paddle */ + if (pad_width==PAD_WIDTH) + { + pad_width=SHORT_PAD_WIDTH; + pad_pos_x+=(PAD_WIDTH-SHORT_PAD_WIDTH)/2; + } + else if (pad_width==LONG_PAD_WIDTH) + { + pad_width=PAD_WIDTH; + pad_pos_x+=(LONG_PAD_WIDTH-PAD_WIDTH)/2; + } + break; } + /* Disable the powerup (it was picked up) */ + brick[bnum].poweruse = false; + } - if (brick[bnum].powertop>PAD_POS_Y) - { - /* Disable the powerup (it was missed) */ - brick[bnum].poweruse = false; - } + if (brick[bnum].powertop>PAD_POS_Y) + { + /* Disable the powerup (it was missed) */ + brick[bnum].poweruse = false; } - /* The brick is a brick, but it may or may not be in use */ - else if(brick[bnum].used) + + /* Check if any of the active fires hit a brick */ + if (pad_type == SHOOTER) { - /* these lines are used to describe the brick */ - line bot_brick, top_brick, left_brick, rght_brick; - brickx = LEFTMARGIN + j*BRICK_WIDTH; + for (k=0;k<30;k++) + { + /* Use misc_line to check if fire hit brick */ + misc_line.p1.x = fire[k].x_pos; + misc_line.p1.y = fire[k].top; + + misc_line.p2.x = fire[k].x_pos; + misc_line.p2.y = fire[k].top + SPEED_FIRE; - /* Describe the brick for later collision checks */ - /* Setup the bottom of the brick */ - bot_brick.p1.x = brickx; - bot_brick.p1.y = brick[bnum].powertop + BRICK_HEIGHT; - - bot_brick.p2.x = brickx + BRICK_WIDTH; - bot_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; - - /* Setup the top of the brick */ - top_brick.p1.x = brickx; - top_brick.p1.y = brick[bnum].powertop; - - top_brick.p2.x = brickx + BRICK_WIDTH; - top_brick.p2.y = brick[bnum].powertop; - - /* Setup the left of the brick */ - left_brick.p1.x = brickx; - left_brick.p1.y = brick[bnum].powertop; - - left_brick.p2.x = brickx; - left_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; - - /* Setup the right of the brick */ - rght_brick.p1.x = brickx + BRICK_WIDTH; - rght_brick.p1.y = brick[bnum].powertop; - - rght_brick.p2.x = brickx + BRICK_WIDTH; - rght_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; - - /* Check if any of the active fires hit a brick */ - if (pad_type == SHOOTER) - { - for (k=0;k<30;k++) + /* If the fire hit the brick take care of it */ + if (brick[bnum].used && fire[k].top > 0 && + check_lines(&misc_line, &bot_brick, &pt_hit)) { - /* Use misc_line to check if fire hit brick */ - misc_line.p1.x = fire[k].x_pos; - misc_line.p1.y = fire[k].top; - - misc_line.p2.x = fire[k].x_pos; - misc_line.p2.y = fire[k].top + SPEED_FIRE; - - /* If the fire hit the brick take care of it */ - if (fire[k].top > 0 && - check_lines(&misc_line, &bot_brick, - &pt_hit)) - { - score+=13; - /* De-activate the fire */ - fire[k].top=-1; - brick_hit(bnum); - } + score+=13; + /* De-activate the fire */ + fire[k].top=-1; + brick_hit(bnum); } } + } - /* Draw the brick */ + /* Draw the brick if it is used*/ + if (brick[bnum].used) + { rb->lcd_bitmap_part(brickmania_bricks,0, INT3(BRICK_HEIGHT)*brick[bnum].color, STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_bricks, BMPHEIGHT_brickmania_bricks), INT3(brickx), - INT3(brick[bnum].powertop), + INT3(bricky), INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) ); - #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ if (brick[bnum].hiteffect > 0) rb->lcd_bitmap_transparent_part(brickmania_break,0, @@ -1500,12 +1593,14 @@ BMPWIDTH_brickmania_break, BMPHEIGHT_brickmania_break), INT3(brickx), - INT3(brick[bnum].powertop), + INT3(bricky), INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) ); #endif - - /* Check if any balls collided with the brick */ - for(k=0; k=0) { /* No lives left reset game */ - brickmania_init_game(false); + brickmania_init_game(0); brickmania_sleep(2); - rb->button_clear_queue(); } } } @@ -1773,9 +1875,8 @@ level++; if (difficulty==NORMAL) score+=100; - brickmania_init_game(true); + brickmania_init_game(1); brickmania_sleep(2); - rb->button_clear_queue(); } else { @@ -1799,8 +1900,9 @@ } } - int button=rb->button_get(false); - int move_button = rb->button_status(); + int move_button,button; + int button_right,button_left; + button=rb->button_get(false); #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN) /* FIXME: Should probably check remote hold here */ @@ -1809,46 +1911,44 @@ #endif #ifdef HAVE_TOUCHSCREEN - if( move_button & BUTTON_TOUCHSCREEN) + if(button & BUTTON_TOUCHSCREEN) { - int data; short touch_x, touch_y; - rb->button_status_wdata(&data); - touch_x = FIXED3(data >> 16); - touch_y = FIXED3(data & 0xffff); - - if(flip_sides) + touch_x = rb->button_get_data() >> 16; + touch_y = rb->button_get_data() & 0xffff; + if(touch_y >= PAD_POS_Y && touch_y <= PAD_POS_Y+PAD_HEIGHT) { - pad_pos_x = GAMESCREEN_WIDTH - (touch_x + pad_width/2); + pad_pos_x += (flip_sides ? -1 : 1) * + ( (touch_x-pad_pos_x-pad_width/2) / 4 ); + + if(pad_pos_x < 0) + pad_pos_x = 0; + else if(pad_pos_x+pad_width > GAMESCREEN_WIDTH) + pad_pos_x = GAMESCREEN_WIDTH-pad_width; + for(k=0;k GAMESCREEN_WIDTH) - pad_pos_x = GAMESCREEN_WIDTH-pad_width; - for(k=0; kbutton_status(); #ifdef ALTRIGHT - button_right = move_button & (RIGHT | ALTRIGHT); - button_left = move_button & (LEFT | ALTLEFT); + button_right=( (move_button & RIGHT) || + (move_button & ALTRIGHT)); + button_left=((move_button & LEFT) || (move_button & ALTLEFT)); #else - button_right =((move_button & RIGHT)|| SCROLL_FWD(move_button)); - button_left =((move_button & LEFT) ||SCROLL_BACK(move_button)); + button_right=((move_button & RIGHT) || (SCROLL_FWD(button))); + button_left=((move_button & LEFT) || (SCROLL_BACK(button))); #endif if ((game_state==ST_PAUSE) && (button_right || button_left)) continue; - if ((button_right && !flip_sides) || - (button_left && flip_sides)) + if ((button_right && flip_sides==false) || + (button_left && flip_sides==true)) { if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH) { @@ -1865,8 +1965,8 @@ pad_pos_x+=SPEED_PAD; } } - else if ((button_left && !flip_sides) || - (button_right && flip_sides)) + else if ((button_left && flip_sides==false) || + (button_right && flip_sides==true)) { if (pad_pos_x-SPEED_PAD < 0) { @@ -1883,20 +1983,17 @@ pad_pos_x-=SPEED_PAD; } } +#ifdef HAVE_TOUCHSCREEN } - - switch(button) - { -#if defined(HAVE_TOUCHSCREEN) - case (BUTTON_REL | BUTTON_TOUCHSCREEN): #endif + + + switch(button) { case UP: case SELECT: - if (game_state==ST_READY) - { + if (game_state==ST_READY) { /* Initialize used balls starting speed */ - for(k=0 ; k < used_balls ; k++) - { + for(k=0 ; k < used_balls ; k++) { ball[k].speedy = SPEED_4Q_Y; if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2) { @@ -1962,17 +2059,15 @@ INT3(GAMESCREEN_HEIGHT - GAMEOVER_HEIGHT)/2, INT3(GAMEOVER_WIDTH),INT3(GAMEOVER_HEIGHT) ); #endif + rb->splash(HZ*2, s); rb->lcd_update(); brickmania_sleep(2); return 0; } - - /* Game always needs to yield for other threads */ - rb->yield(); - - /* Sleep for a bit if there is time to spare */ if (end > *rb->current_tick) rb->sleep(end-*rb->current_tick); + else + rb->yield(); } return 0; } @@ -1986,10 +2081,6 @@ highscore_load(HIGH_SCORE,highest,NUM_SCORES); configfile_load(CONFIG_FILE_NAME,config,1,0); last_difficulty = difficulty; - -#ifdef HAVE_TOUCHSCREEN - rb->touchscreen_set_mode(TOUCHSCREEN_POINT); -#endif rb->lcd_setfont(FONT_SYSFIXED); #if LCD_DEPTH > 1 @@ -2002,10 +2093,8 @@ rb->srand( *rb->current_tick ); brickmania_loadgame(); resume_file = resume; - while(!brickmania_game_loop()) - { - if(!resume) - { + while(brickmania_game_loop() == 0) { + if(!resume) { int position = highscore_update(score, level+1, "", highest, NUM_SCORES); if (position == 0)