summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/bitmaps/native/brickmania_powerups.220x176x16.bmpbin1208 -> 1400 bytes
-rw-r--r--apps/plugins/brickmania.c312
2 files changed, 189 insertions, 123 deletions
diff --git a/apps/plugins/bitmaps/native/brickmania_powerups.220x176x16.bmp b/apps/plugins/bitmaps/native/brickmania_powerups.220x176x16.bmp
index 744b1afa51..91ece1048d 100644
--- a/apps/plugins/bitmaps/native/brickmania_powerups.220x176x16.bmp
+++ b/apps/plugins/bitmaps/native/brickmania_powerups.220x176x16.bmp
Binary files differ
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index 2b75ce8f95..653d00d975 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -440,18 +440,14 @@ static unsigned char levels[29][8][10] = {
440}; 440};
441 441
442int pad_pos_x,x,y; 442int pad_pos_x,x,y;
443int ball_pos_x;
444int ball_pos_y;
445int bally,balltempy;
446int ballx,balltempx;
447int life; 443int life;
448int start_game,con_game; 444int start_game,con_game;
449int pad_type; 445int pad_type;
450int on_the_pad=0; /* for glue pad */
451int score=0,vscore=0; 446int score=0,vscore=0;
452bool flip_sides=false; 447bool flip_sides=false;
453int cur_level=0; 448int cur_level=0;
454int brick_on_board=0; 449int brick_on_board=0;
450int used_balls=1;
455 451
456typedef struct cube { 452typedef struct cube {
457 int powertop; 453 int powertop;
@@ -464,7 +460,18 @@ typedef struct cube {
464} cube; 460} cube;
465cube brick[80]; 461cube brick[80];
466 462
463typedef struct balls {
464 int pos_x;
465 int pos_y;
466 int y;
467 int tempy;
468 int x;
469 int tempx;
470 bool glue;
471} balls;
467 472
473#define MAX_BALLS 10
474balls ball[MAX_BALLS];
468 475
469typedef struct sfire { 476typedef struct sfire {
470 int top; 477 int top;
@@ -483,17 +490,24 @@ static struct configdata config[] =
483void int_game(int new_game) 490void int_game(int new_game)
484{ 491{
485 int i,j; 492 int i,j;
486 ballx=0; 493
487 bally=0;
488 pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2; 494 pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2;
489 ball_pos_y=PAD_POS_Y-BALL; 495
490 ball_pos_x=pad_pos_x+(PAD_WIDTH/2)-2; 496 for(i=0;i<MAX_BALLS;i++) {
497 ball[i].x=0;
498 ball[i].y=0;
499 ball[i].tempy=0;
500 ball[i].tempx=0;
501 ball[i].pos_y=PAD_POS_Y-BALL;
502 ball[i].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
503 ball[i].glue=false;
504 }
505
506 used_balls=1;
491 start_game =1; 507 start_game =1;
492 con_game =0; 508 con_game =0;
493 pad_type=0; 509 pad_type=0;
494 on_the_pad=0; 510
495 balltempy=0;
496 balltempx=0;
497 flip_sides=false; 511 flip_sides=false;
498 512
499 if (new_game==1) 513 if (new_game==1)
@@ -695,7 +709,7 @@ int help(int when)
695 return NULL; 709 return NULL;
696} 710}
697 711
698int pad_check(int ballxc,int mode,int pon) 712int pad_check(int ballxc, int mode, int pon ,int ballnum)
699{ 713{
700 /* pon: positive(1) or negative(0) */ 714 /* pon: positive(1) or negative(0) */
701 715
@@ -705,7 +719,7 @@ int pad_check(int ballxc,int mode,int pon)
705 else 719 else
706 return ballxc; 720 return ballxc;
707 } else { 721 } else {
708 if (ballx > 0) 722 if (ball[ballnum].x > 0)
709 return ballxc; 723 return ballxc;
710 else 724 else
711 return ballxc*-1; 725 return ballxc*-1;
@@ -795,7 +809,8 @@ int game_loop(void){
795 } 809 }
796 810
797 /* draw the ball */ 811 /* draw the ball */
798 rb->lcd_bitmap(brickmania_ball,ball_pos_x, ball_pos_y, BALL, BALL); 812 for(i=0;i<used_balls;i++)
813 rb->lcd_bitmap(brickmania_ball,ball[i].pos_x, ball[i].pos_y, BALL, BALL);
799 814
800 if (brick_on_board==0) brick_on_board--; 815 if (brick_on_board==0) brick_on_board--;
801 816
@@ -811,7 +826,7 @@ int game_loop(void){
811 /* the bricks */ 826 /* the bricks */
812 for (i=0;i<=7;i++) { 827 for (i=0;i<=7;i++) {
813 for (j=0;j<=9;j++) { 828 for (j=0;j<=9;j++) {
814 if (brick[i*10+j].power<6) { 829 if (brick[i*10+j].power<7) {
815 if (brick[i*10+j].poweruse==2) { 830 if (brick[i*10+j].poweruse==2) {
816 if (con_game!=1) 831 if (con_game!=1)
817 brick[i*10+j].powertop+=2; 832 brick[i*10+j].powertop+=2;
@@ -842,12 +857,14 @@ int game_loop(void){
842 case 3: 857 case 3:
843 score+=47; 858 score+=47;
844 pad_type=2; 859 pad_type=2;
845 on_the_pad=0; 860 for(k=0;k<used_balls;k++)
861 ball[k].glue=false;
846 break; 862 break;
847 case 4: 863 case 4:
848 score+=23; 864 score+=23;
849 pad_type=0; 865 pad_type=0;
850 on_the_pad=0; 866 for(k=0;k<used_balls;k++)
867 ball[k].glue=false;
851 flip_sides=false; 868 flip_sides=false;
852 break; 869 break;
853 case 5: 870 case 5:
@@ -855,6 +872,12 @@ int game_loop(void){
855 sec_count=*rb->current_tick+HZ; 872 sec_count=*rb->current_tick+HZ;
856 num_count=10; 873 num_count=10;
857 flip_sides=!flip_sides; 874 flip_sides=!flip_sides;
875 break;
876 case 6:
877 score+=23;
878 used_balls++;
879 ball[used_balls-1].x= rb->rand()%1 == 0 ? -1 : 1;
880 ball[used_balls-1].y= -4;
858 break; 881 break;
859 } 882 }
860 brick[i*10+j].poweruse=1; 883 brick[i*10+j].poweruse=1;
@@ -888,23 +911,26 @@ int game_loop(void){
888 911
889 if (brick[i*10+j].used==1){ 912 if (brick[i*10+j].used==1){
890 rb->lcd_bitmap_part(brickmania_bricks,0,BRICK_HEIGHT*brick[i*10+j].color,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, 30+i*8, BRICK_WIDTH, BRICK_HEIGHT); 913 rb->lcd_bitmap_part(brickmania_bricks,0,BRICK_HEIGHT*brick[i*10+j].color,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, 30+i*8, BRICK_WIDTH, BRICK_HEIGHT);
891 rb->lcd_bitmap_transparent_part(brickmania_break,0,BRICK_HEIGHT*brick[i*10+j].hiteffect,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, 30+i*8, BRICK_WIDTH, BRICK_HEIGHT); 914 if (brick[i*10+j].hiteffect>0)
915 rb->lcd_bitmap_transparent_part(brickmania_break,0,BRICK_HEIGHT*brick[i*10+j].hiteffect,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, 30+i*8, BRICK_WIDTH, BRICK_HEIGHT);
892 } 916 }
893 if (ball_pos_y <100) { 917
918 for(k=0;k<used_balls;k++) {
919 if (ball[k].pos_y <100) {
894 if (brick[i*10+j].used==1) { 920 if (brick[i*10+j].used==1) {
895 if ((ball_pos_x+ballx+3 >= brickx && ball_pos_x+ballx+3 <= brickx+BRICK_WIDTH) && ((bricky-4<ball_pos_y+BALL && bricky>ball_pos_y+BALL) || (bricky+4>ball_pos_y+BALL+BALL && bricky<ball_pos_y+BALL+BALL)) && (bally >0)){ 921 if ((ball[k].pos_x+ball[k].x+3 >= brickx && ball[k].pos_x+ball[k].x+3 <= brickx+BRICK_WIDTH) && ((bricky-4<ball[k].pos_y+BALL && bricky>ball[k].pos_y+BALL) || (bricky+4>ball[k].pos_y+BALL+BALL && bricky<ball[k].pos_y+BALL+BALL)) && (ball[k].y >0)){
896 balltempy=bricky-ball_pos_y-BALL; 922 ball[k].tempy=bricky-ball[k].pos_y-BALL;
897 } else if ((ball_pos_x+ballx+3 >= brickx && ball_pos_x+ballx+3 <= brickx+BRICK_WIDTH) && ((bricky+BRICK_HEIGHT+4>ball_pos_y && bricky+BRICK_HEIGHT<ball_pos_y) || (bricky+BRICK_HEIGHT-4<ball_pos_y-BALL && bricky+BRICK_HEIGHT>ball_pos_y-BALL)) && (bally <0)){ 923 } else if ((ball[k].pos_x+ball[k].x+3 >= brickx && ball[k].pos_x+ball[k].x+3 <= brickx+BRICK_WIDTH) && ((bricky+BRICK_HEIGHT+4>ball[k].pos_y && bricky+BRICK_HEIGHT<ball[k].pos_y) || (bricky+BRICK_HEIGHT-4<ball[k].pos_y-BALL && bricky+BRICK_HEIGHT>ball[k].pos_y-BALL)) && (ball[k].y <0)){
898 balltempy=-(ball_pos_y-(bricky+BRICK_HEIGHT)); 924 ball[k].tempy=-(ball[k].pos_y-(bricky+BRICK_HEIGHT));
899 } 925 }
900 926
901 if ((ball_pos_y+3 >= bricky && ball_pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx-4<ball_pos_x+BALL && brickx>ball_pos_x+BALL) || (brickx+4>ball_pos_x+BALL+BALL && brickx<ball_pos_x+BALL+BALL)) && (ballx >0)) { 927 if ((ball[k].pos_y+3 >= bricky && ball[k].pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx-4<ball[k].pos_x+BALL && brickx>ball[k].pos_x+BALL) || (brickx+4>ball[k].pos_x+BALL+BALL && brickx<ball[k].pos_x+BALL+BALL)) && (ball[k].x >0)) {
902 balltempx=brickx-ball_pos_x-BALL; 928 ball[k].tempx=brickx-ball[k].pos_x-BALL;
903 } else if ((ball_pos_y+bally+3 >= bricky && ball_pos_y+bally+3 <= bricky+BRICK_HEIGHT) && ((brickx+BRICK_WIDTH+4>ball_pos_x && brickx+BRICK_WIDTH<ball_pos_x) || (brickx+BRICK_WIDTH-4<ball_pos_x-BALL && brickx+BRICK_WIDTH>ball_pos_x-BALL)) && (ballx <0)) { 929 } else if ((ball[k].pos_y+ball[k].y+3 >= bricky && ball[k].pos_y+ball[k].y+3 <= bricky+BRICK_HEIGHT) && ((brickx+BRICK_WIDTH+4>ball[k].pos_x && brickx+BRICK_WIDTH<ball[k].pos_x) || (brickx+BRICK_WIDTH-4<ball[k].pos_x-BALL && brickx+BRICK_WIDTH>ball[k].pos_x-BALL)) && (ball[k].x <0)) {
904 balltempx=-(ball_pos_x-(brickx+BRICK_WIDTH)); 930 ball[k].tempx=-(ball[k].pos_x-(brickx+BRICK_WIDTH));
905 } 931 }
906 932
907 if ((ball_pos_x+3 >= brickx && ball_pos_x+3 <= brickx+BRICK_WIDTH) && ((bricky+BRICK_HEIGHT==ball_pos_y) || (bricky+BRICK_HEIGHT-6<=ball_pos_y && bricky+BRICK_HEIGHT>ball_pos_y)) && (bally <0)) { /* bottom line */ 933 if ((ball[k].pos_x+3 >= brickx && ball[k].pos_x+3 <= brickx+BRICK_WIDTH) && ((bricky+BRICK_HEIGHT==ball[k].pos_y) || (bricky+BRICK_HEIGHT-6<=ball[k].pos_y && bricky+BRICK_HEIGHT>ball[k].pos_y)) && (ball[k].y <0)) { /* bottom line */
908 if (brick[i*10+j].hits > 0){ 934 if (brick[i*10+j].hits > 0){
909 brick[i*10+j].hits--; 935 brick[i*10+j].hits--;
910 brick[i*10+j].hiteffect++; 936 brick[i*10+j].hiteffect++;
@@ -916,8 +942,8 @@ int game_loop(void){
916 brick[i*10+j].poweruse=2; 942 brick[i*10+j].poweruse=2;
917 } 943 }
918 944
919 bally = bally*-1; 945 ball[k].y = ball[k].y*-1;
920 } else if ((ball_pos_x+3 >= brickx && ball_pos_x+3 <= brickx+BRICK_WIDTH) && ((bricky==ball_pos_y+BALL) || (bricky+6>=ball_pos_y+BALL && bricky<ball_pos_y+BALL)) && (bally >0)) { /* top line */ 946 } else if ((ball[k].pos_x+3 >= brickx && ball[k].pos_x+3 <= brickx+BRICK_WIDTH) && ((bricky==ball[k].pos_y+BALL) || (bricky+6>=ball[k].pos_y+BALL && bricky<ball[k].pos_y+BALL)) && (ball[k].y >0)) { /* top line */
921 if (brick[i*10+j].hits > 0){ 947 if (brick[i*10+j].hits > 0){
922 brick[i*10+j].hits--; 948 brick[i*10+j].hits--;
923 brick[i*10+j].hiteffect++; 949 brick[i*10+j].hiteffect++;
@@ -929,10 +955,10 @@ int game_loop(void){
929 brick[i*10+j].poweruse=2; 955 brick[i*10+j].poweruse=2;
930 } 956 }
931 957
932 bally = bally*-1; 958 ball[k].y = ball[k].y*-1;
933 } 959 }
934 960
935 if ((ball_pos_y+3 >= bricky && ball_pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx==ball_pos_x+BALL) || (brickx+6>=ball_pos_x+BALL && brickx<ball_pos_x+BALL)) && (ballx > 0)) { /* left line */ 961 if ((ball[k].pos_y+3 >= bricky && ball[k].pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx==ball[k].pos_x+BALL) || (brickx+6>=ball[k].pos_x+BALL && brickx<ball[k].pos_x+BALL)) && (ball[k].x > 0)) { /* left line */
936 if (brick[i*10+j].hits > 0){ 962 if (brick[i*10+j].hits > 0){
937 brick[i*10+j].hits--; 963 brick[i*10+j].hits--;
938 brick[i*10+j].hiteffect++; 964 brick[i*10+j].hiteffect++;
@@ -943,9 +969,9 @@ int game_loop(void){
943 if (brick[i*10+j].power!=10) 969 if (brick[i*10+j].power!=10)
944 brick[i*10+j].poweruse=2; 970 brick[i*10+j].poweruse=2;
945 } 971 }
946 ballx = ballx*-1; 972 ball[k].x = ball[k].x*-1;
947 973
948 } else if ((ball_pos_y+3 >= bricky && ball_pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx+BRICK_WIDTH==ball_pos_x) || (brickx+BRICK_WIDTH-6<=ball_pos_x && brickx+BRICK_WIDTH>ball_pos_x)) && (ballx < 0)) { /* Right line */ 974 } else if ((ball[k].pos_y+3 >= bricky && ball[k].pos_y+3 <= bricky+BRICK_HEIGHT) && ((brickx+BRICK_WIDTH==ball[k].pos_x) || (brickx+BRICK_WIDTH-6<=ball[k].pos_x && brickx+BRICK_WIDTH>ball[k].pos_x)) && (ball[k].x < 0)) { /* Right line */
949 if (brick[i*10+j].hits > 0){ 975 if (brick[i*10+j].hits > 0){
950 brick[i*10+j].hits--; 976 brick[i*10+j].hits--;
951 brick[i*10+j].hiteffect++; 977 brick[i*10+j].hiteffect++;
@@ -957,7 +983,7 @@ int game_loop(void){
957 brick[i*10+j].poweruse=2; 983 brick[i*10+j].poweruse=2;
958 } 984 }
959 985
960 ballx = ballx*-1; 986 ball[k].x = ball[k].x*-1;
961 } 987 }
962 988
963 if (brick[i*10+j].used==0){ 989 if (brick[i*10+j].used==0){
@@ -966,76 +992,102 @@ int game_loop(void){
966 } 992 }
967 } 993 }
968 } 994 }
969 } 995 } /* for k */
970 } 996 } /* for j */
997 } /* for i */
971 998
972 /* draw the pad */ 999 /* draw the pad */
973 rb->lcd_bitmap_part(brickmania_pads,0,pad_type*PAD_HEIGHT,PAD_WIDTH,pad_pos_x, PAD_POS_Y, PAD_WIDTH, PAD_HEIGHT); 1000 rb->lcd_bitmap_part(brickmania_pads,0,pad_type*PAD_HEIGHT,PAD_WIDTH,pad_pos_x, PAD_POS_Y, PAD_WIDTH, PAD_HEIGHT);
974 1001
975 if ((ball_pos_x >= pad_pos_x && ball_pos_x <= pad_pos_x+PAD_WIDTH) && (PAD_POS_Y-4<ball_pos_y+BALL && PAD_POS_Y>ball_pos_y+BALL) && (bally >0)) 1002 for(k=0;k<used_balls;k++) {
976 balltempy=PAD_POS_Y-ball_pos_y-BALL; 1003
977 else if ((4>ball_pos_y && 0<ball_pos_y) && (bally <0)) 1004 if ((ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH) && (PAD_POS_Y-4<ball[k].pos_y+BALL && PAD_POS_Y>ball[k].pos_y+BALL) && (ball[k].y >0))
978 balltempy=-ball_pos_y; 1005 ball[k].tempy=PAD_POS_Y-ball[k].pos_y-BALL;
979 if ((LCD_WIDTH-4<ball_pos_x+BALL && LCD_WIDTH>ball_pos_x+BALL) && (ballx >0)) 1006 else if ((4>ball[k].pos_y && 0<ball[k].pos_y) && (ball[k].y <0))
980 balltempx=LCD_WIDTH-ball_pos_x-BALL; 1007 ball[k].tempy=-ball[k].pos_y;
981 else if ((4>ball_pos_x && 0<ball_pos_x) && (ballx <0)) 1008 if ((LCD_WIDTH-4<ball[k].pos_x+BALL && LCD_WIDTH>ball[k].pos_x+BALL) && (ball[k].x >0))
982 balltempx=-ball_pos_x; 1009 ball[k].tempx=LCD_WIDTH-ball[k].pos_x-BALL;
983 1010 else if ((4>ball[k].pos_x && 0<ball[k].pos_x) && (ball[k].x <0))
984 /* top line */ 1011 ball[k].tempx=-ball[k].pos_x;
985 if (ball_pos_y<= 0) 1012
986 bally = bally*-1; 1013 /* top line */
987 /* bottom line */ 1014 if (ball[k].pos_y<= 0)
988 else if (ball_pos_y+BALL >= LCD_HEIGHT) { 1015 ball[k].y = ball[k].y*-1;
989 life--; 1016 /* bottom line */
990 if (life>=0){ 1017 else if (ball[k].pos_y+BALL >= LCD_HEIGHT) {
991 int_game(0); 1018 if (used_balls>1) {
992 rb->sleep(HZ*2); 1019 used_balls--;
993 } 1020 ball[k].pos_x = ball[used_balls].pos_x;
994 } 1021 ball[k].pos_y = ball[used_balls].pos_y;
995 1022 ball[k].y = ball[used_balls].y;
996 /* left line ,right line */ 1023 ball[k].tempy = ball[used_balls].tempy;
997 if ((ball_pos_x <= 0) || (ball_pos_x+BALL >= LCD_WIDTH)) 1024 ball[k].x = ball[used_balls].x;
998 ballx = ballx*-1; 1025 ball[k].tempx = ball[used_balls].tempx;
999 1026 ball[k].glue = ball[used_balls].glue;
1000 if ((ball_pos_y+5 >= PAD_POS_Y && (ball_pos_x >= pad_pos_x && ball_pos_x <= pad_pos_x+PAD_WIDTH)) && 1027
1001 start_game != 1 && on_the_pad==0) { 1028 ball[used_balls].x=0;
1002 if ((ball_pos_x+3 >= pad_pos_x && ball_pos_x+3 <= pad_pos_x+5) || (ball_pos_x +2>= pad_pos_x+35 && ball_pos_x+2 <= pad_pos_x+40)) { 1029 ball[used_balls].y=0;
1003 bally = 2*-1; 1030 ball[used_balls].tempy=0;
1004 if (ball_pos_x != 0 && ball_pos_x+BALL!=LCD_WIDTH) 1031 ball[used_balls].tempx=0;
1005 ballx = pad_check(6,0,ball_pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1); 1032 ball[used_balls].pos_y=PAD_POS_Y-BALL;
1006 } else if ((ball_pos_x+3 >= pad_pos_x+5 && ball_pos_x+3 <= pad_pos_x+10) || (ball_pos_x+2 >= pad_pos_x+30 && ball_pos_x+2 <= pad_pos_x+35)) { 1033 ball[used_balls].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
1007 bally = 3*-1; 1034
1008 1035 k--;
1009 if (ball_pos_x != 0 && ball_pos_x+BALL!=LCD_WIDTH) 1036 continue;
1010 ballx = pad_check(4,0,ball_pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1);
1011 } else if ((ball_pos_x+3 >= pad_pos_x+10 && ball_pos_x+3 <= pad_pos_x+15) || (ball_pos_x+2 >= pad_pos_x+25 && ball_pos_x+2 <= pad_pos_x+30)) {
1012 bally = 4*-1;
1013
1014 if (ball_pos_x != 0 && ball_pos_x+BALL!=LCD_WIDTH)
1015 ballx = pad_check(3,0,ball_pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1);
1016 } else if ((ball_pos_x+3 >= pad_pos_x+13 && ball_pos_x+3 <= pad_pos_x+18) || (ball_pos_x+2 >= pad_pos_x+22 && ball_pos_x+2 <= pad_pos_x+25)) {
1017 bally = 4*-1;
1018 if (ball_pos_x != 0 && ball_pos_x+BALL!=LCD_WIDTH)
1019 ballx = pad_check(2,1,NULL);
1020 } else { 1037 } else {
1021 bally = 4*-1; 1038 life--;
1039 if (life>=0){
1040 int_game(0);
1041 rb->sleep(HZ*2);
1042 }
1022 } 1043 }
1023 } 1044 }
1024 1045
1025 if (on_the_pad!=1) { 1046 /* left line ,right line */
1026 ball_pos_x+=balltempx!=0?balltempx:ballx; 1047 if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH))
1027 ball_pos_y+=balltempy!=0?balltempy:bally; 1048 ball[k].x = ball[k].x*-1;
1028 1049
1029 balltempy=0; 1050 if ((ball[k].pos_y+5 >= PAD_POS_Y && (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) &&
1030 balltempx=0; 1051 start_game != 1 && !ball[k].glue) {
1031 } 1052 if ((ball[k].pos_x+3 >= pad_pos_x && ball[k].pos_x+3 <= pad_pos_x+5) || (ball[k].pos_x +2>= pad_pos_x+35 && ball[k].pos_x+2 <= pad_pos_x+40)) {
1032 1053 ball[k].y = 2*-1;
1033 if (ball_pos_y+5 >= PAD_POS_Y && (pad_type==1 && on_the_pad==0) && 1054 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1034 (ball_pos_x >= pad_pos_x && ball_pos_x <= pad_pos_x+PAD_WIDTH)){ 1055 ball[k].x = pad_check(6,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1035 bally=0; 1056 } else if ((ball[k].pos_x+3 >= pad_pos_x+5 && ball[k].pos_x+3 <= pad_pos_x+10) || (ball[k].pos_x+2 >= pad_pos_x+30 && ball[k].pos_x+2 <= pad_pos_x+35)) {
1036 on_the_pad=1; 1057 ball[k].y = 3*-1;
1037 } 1058
1038 1059 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1060 ball[k].x = pad_check(4,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1061 } else if ((ball[k].pos_x+3 >= pad_pos_x+10 && ball[k].pos_x+3 <= pad_pos_x+15) || (ball[k].pos_x+2 >= pad_pos_x+25 && ball[k].pos_x+2 <= pad_pos_x+30)) {
1062 ball[k].y = 4*-1;
1063
1064 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1065 ball[k].x = pad_check(3,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1066 } else if ((ball[k].pos_x+3 >= pad_pos_x+13 && ball[k].pos_x+3 <= pad_pos_x+18) || (ball[k].pos_x+2 >= pad_pos_x+22 && ball[k].pos_x+2 <= pad_pos_x+25)) {
1067 ball[k].y = 4*-1;
1068 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1069 ball[k].x = pad_check(2,1,NULL,k);
1070 } else {
1071 ball[k].y = 4*-1;
1072 }
1073 }
1074
1075 if (!ball[k].glue) {
1076 ball[k].pos_x+=ball[k].tempx!=0?ball[k].tempx:ball[k].x;
1077 ball[k].pos_y+=ball[k].tempy!=0?ball[k].tempy:ball[k].y;
1078
1079 ball[k].tempy=0;
1080 ball[k].tempx=0;
1081 }
1082
1083 if (ball[k].pos_y+5 >= PAD_POS_Y && (pad_type==1 && !ball[k].glue) &&
1084 (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)){
1085 ball[k].y=0;
1086 ball[k].pos_y=PAD_POS_Y-BALL;
1087 ball[k].glue=true;
1088 }
1089 } /* for k */
1090
1039 rb->lcd_update(); 1091 rb->lcd_update();
1040 1092
1041 if (brick_on_board < 0) { 1093 if (brick_on_board < 0) {
@@ -1088,19 +1140,26 @@ int game_loop(void){
1088 1140
1089 if ((button_right && flip_sides==false) || (button_left && flip_sides==true)) { 1141 if ((button_right && flip_sides==false) || (button_left && flip_sides==true)) {
1090 if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) { 1142 if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) {
1091 if (start_game==1 || on_the_pad==1) ball_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; 1143 for(k=0;k<used_balls;k++)
1092 pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; 1144 if (start_game==1 || ball[k].glue)
1145 ball[k].pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH;
1146 pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH;
1093 } else { 1147 } else {
1094 if ((start_game==1 || on_the_pad==1)) 1148 for(k=0;k<used_balls;k++)
1095 ball_pos_x+=8; 1149 if ((start_game==1 || ball[k].glue))
1150 ball[k].pos_x+=8;
1096 pad_pos_x+=8; 1151 pad_pos_x+=8;
1097 } 1152 }
1098 } else if ((button_left && flip_sides==false) || (button_right && flip_sides==true)) { 1153 } else if ((button_left && flip_sides==false) || (button_right && flip_sides==true)) {
1099 if (pad_pos_x-8 < 0) { 1154 if (pad_pos_x-8 < 0) {
1100 if (start_game==1 || on_the_pad==1) ball_pos_x-=pad_pos_x; 1155 for(k=0;k<used_balls;k++)
1156 if (start_game==1 || ball[k].glue)
1157 ball[k].pos_x-=pad_pos_x;
1101 pad_pos_x-=pad_pos_x; 1158 pad_pos_x-=pad_pos_x;
1102 } else { 1159 } else {
1103 if (start_game==1 || on_the_pad==1) ball_pos_x-=8; 1160 for(k=0;k<used_balls;k++)
1161 if (start_game==1 || ball[k].glue)
1162 ball[k].pos_x-=8;
1104 pad_pos_x-=8; 1163 pad_pos_x-=8;
1105 } 1164 }
1106 } 1165 }
@@ -1109,11 +1168,14 @@ int game_loop(void){
1109 switch(button) { 1168 switch(button) {
1110 case SELECT: 1169 case SELECT:
1111 if (start_game==1 && con_game!=1 && pad_type!=1) { 1170 if (start_game==1 && con_game!=1 && pad_type!=1) {
1112 bally=-4; 1171 for(k=0;k<used_balls;k++){
1113 ballx=pad_pos_x+(PAD_WIDTH/2)-2>=LCD_WIDTH/2?2:-2; 1172 ball[k].y=-4;
1173 ball[k].x=pad_pos_x+(PAD_WIDTH/2)-2>=LCD_WIDTH/2?2:-2;
1174 }
1114 start_game =0; 1175 start_game =0;
1115 } else if (pad_type==1 && on_the_pad==1) { 1176 } else if (pad_type==1) {
1116 on_the_pad=0; 1177 for(k=0;k<used_balls;k++)
1178 ball[k].glue=false;
1117 if (start_game!=1 && con_game==1) { 1179 if (start_game!=1 && con_game==1) {
1118 start_game =0; 1180 start_game =0;
1119 con_game=0; 1181 con_game=0;
@@ -1127,8 +1189,10 @@ int game_loop(void){
1127 fire[tfire].top=PAD_POS_Y-7; 1189 fire[tfire].top=PAD_POS_Y-7;
1128 fire[tfire].left=pad_pos_x+PAD_WIDTH-1; 1190 fire[tfire].left=pad_pos_x+PAD_WIDTH-1;
1129 } else if (con_game==1 && start_game!=1) { 1191 } else if (con_game==1 && start_game!=1) {
1130 ballx=x; 1192 for(k=0;k<used_balls;k++){
1131 bally=y; 1193 ball[k].x=x;
1194 ball[k].y=y;
1195 }
1132 con_game=0; 1196 con_game=0;
1133 } 1197 }
1134 break; 1198 break;
@@ -1140,8 +1204,9 @@ int game_loop(void){
1140 int_game(1); 1204 int_game(1);
1141 break; 1205 break;
1142 case 1: 1206 case 1:
1143 if (ballx!=0 && bally !=0) 1207 for(k=0;k<used_balls;k++)
1144 con_game=1; 1208 if (ball[k].x!=0 && ball[k].y !=0)
1209 con_game=1;
1145 break; 1210 break;
1146 case 2: 1211 case 2:
1147 if (help(1)==1) return 1; 1212 if (help(1)==1) return 1;
@@ -1150,10 +1215,12 @@ int game_loop(void){
1150 return 1; 1215 return 1;
1151 break; 1216 break;
1152 }; 1217 };
1153 if (ballx!=0) x=ballx; 1218 for(k=0;k<used_balls;k++){
1154 ballx=0; 1219 if (ball[k].x!=0) x=ball[k].x;
1155 if (bally!=0) y=bally; 1220 ball[k].x=0;
1156 bally=0; 1221 if (ball[k].y!=0) y=ball[k].y;
1222 ball[k].y=0;
1223 }
1157 break; 1224 break;
1158 } 1225 }
1159 } else { 1226 } else {
@@ -1167,8 +1234,10 @@ int game_loop(void){
1167 rb->sleep(HZ * 3); 1234 rb->sleep(HZ * 3);
1168 } 1235 }
1169 1236
1170 ballx=0; 1237 for(k=0;k<used_balls;k++){
1171 bally=0; 1238 ball[k].x=0;
1239 ball[k].y=0;
1240 }
1172 1241
1173 switch(game_menu(0)){ 1242 switch(game_menu(0)){
1174 case 0: 1243 case 0:
@@ -1198,9 +1267,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1198 (void)parameter; 1267 (void)parameter;
1199 rb = api; 1268 rb = api;
1200 1269
1201 bally=0;
1202 ballx=0;
1203
1204 /* Permanently enable the backlight (unless the user has turned it off) */ 1270 /* Permanently enable the backlight (unless the user has turned it off) */
1205 if (rb->global_settings->backlight_timeout > 0) 1271 if (rb->global_settings->backlight_timeout > 0)
1206 rb->backlight_set_timeout(1); 1272 rb->backlight_set_timeout(1);