summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-03-03 07:24:34 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-03-03 07:24:34 +0000
commita26d315d0592928dbfbb4de0e3636b338d17870d (patch)
treef4ae4ba36b3ac922c2670248e460de1e7f691220 /apps/plugins
parent8aa5bd11b21dd85cb0fadebeeb7c506f85237266 (diff)
downloadrockbox-a26d315d0592928dbfbb4de0e3636b338d17870d.tar.gz
rockbox-a26d315d0592928dbfbb4de0e3636b338d17870d.zip
Code-policed: cleaned off tabs, indented fine, narrowed to 80 columns (mostly)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8892 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/brickmania.c1113
1 files changed, 646 insertions, 467 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index 2b2671d6be..75f7e3422d 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2005 Ben Basha (Paprica) 10 * Copyright (C) 2005, 2006 Ben Basha (Paprica)
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -144,7 +144,7 @@ extern const fb_data brickmania_bricks[];
144 to 10ms. 144 to 10ms.
145*/ 145*/
146#define CYCLETIME 30 146#define CYCLETIME 30
147 147
148/* Offsets for LCDS > 220x176 */ 148/* Offsets for LCDS > 220x176 */
149#define XOFS ((LCD_WIDTH-220)/2) 149#define XOFS ((LCD_WIDTH-220)/2)
150#define YOFS ((LCD_HEIGHT-176)/2) 150#define YOFS ((LCD_HEIGHT-176)/2)
@@ -349,7 +349,7 @@ extern const fb_data brickmania_bricks[];
349#endif 349#endif
350 350
351int levels_num = 29; 351int levels_num = 29;
352 352
353static unsigned char levels[29][8][10] = { 353static unsigned char levels[29][8][10] = {
354 { /* level1 */ 354 { /* level1 */
355 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1}, 355 {0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
@@ -695,79 +695,83 @@ static struct configdata config[] =
695void int_game(int new_game) 695void int_game(int new_game)
696{ 696{
697 int i,j; 697 int i,j;
698 698
699 pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2; 699 pad_pos_x=LCD_WIDTH/2-PAD_WIDTH/2;
700 700
701 for(i=0;i<MAX_BALLS;i++) { 701 for(i=0;i<MAX_BALLS;i++) {
702 ball[i].x=0; 702 ball[i].x=0;
703 ball[i].y=0; 703 ball[i].y=0;
704 ball[i].tempy=0; 704 ball[i].tempy=0;
705 ball[i].tempx=0; 705 ball[i].tempx=0;
706 ball[i].pos_y=PAD_POS_Y-BALL; 706 ball[i].pos_y=PAD_POS_Y-BALL;
707 ball[i].pos_x=pad_pos_x+(PAD_WIDTH/2)-2; 707 ball[i].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
708 ball[i].glue=false; 708 ball[i].glue=false;
709 } 709 }
710 710
711 used_balls=1; 711 used_balls=1;
712 start_game =1; 712 start_game =1;
713 con_game =0; 713 con_game =0;
714 pad_type=0; 714 pad_type=0;
715 715
716 flip_sides=false; 716 flip_sides=false;
717 717
718 if (new_game==1) 718 if (new_game==1)
719 brick_on_board=0; 719 brick_on_board=0;
720 720
721 for(i=0;i<=7;i++){ 721 for(i=0;i<=7;i++) {
722 for(j=0;j<=9;j++){ 722 for(j=0;j<=9;j++) {
723 brick[i*10+j].poweruse=(levels[cur_level][i][j]==0?0:1); 723 brick[i*10+j].poweruse=(levels[cur_level][i][j]==0?0:1);
724 if (i*10+j<=30) fire[i*10+j].top=-8; 724 if (i*10+j<=30)
725 if (new_game==1) { 725 fire[i*10+j].top=-8;
726 if (new_game==1) {
727 brick[i*10+j].power=rb->rand()%25;
728 /* +8 make the game with less powerups */
726 729
727 brick[i*10+j].power=rb->rand()%25; /* +8 make the game with less powerups */
728 brick[i*10+j].hits=levels[cur_level][i][j]>=10? 730 brick[i*10+j].hits=levels[cur_level][i][j]>=10?
729 levels[cur_level][i][j]/16-1:0; 731 levels[cur_level][i][j]/16-1:0;
730 brick[i*10+j].hiteffect=0; 732 brick[i*10+j].hiteffect=0;
731 brick[i*10+j].powertop=TOPMARGIN+i*BRICK_HEIGHT+BRICK_HEIGHT; 733 brick[i*10+j].powertop=TOPMARGIN+i*BRICK_HEIGHT+BRICK_HEIGHT;
732 brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1); 734 brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1);
733 brick[i*10+j].color=(levels[cur_level][i][j]>=10? 735 brick[i*10+j].color=(levels[cur_level][i][j]>=10?
734 levels[cur_level][i][j]%16:levels[cur_level][i][j])-1; 736 levels[cur_level][i][j]%16:
735 if (levels[cur_level][i][j]!=0) brick_on_board++; 737 levels[cur_level][i][j])-1;
738 if (levels[cur_level][i][j]!=0)
739 brick_on_board++;
736 } 740 }
737 } 741 }
738 } 742 }
739
740
741} 743}
742 744
743int sw,i,w; 745int sw,i,w;
744 746
745/* sleep timer counting the score */ 747/* sleep timer counting the score */
746void sleep (int secs) { 748void sleep (int secs)
747 bool done=false; 749{
748 char s[20]; 750 bool done=false;
749 int count=0; 751 char s[20];
750 752 int count=0;
751 while (!done) { 753
752 754 while (!done) {
753 if (vscore<score) { 755
754 vscore++; 756 if (vscore<score) {
755 rb->snprintf(s, sizeof(s), "%d", vscore); 757 vscore++;
756 rb->lcd_getstringsize(s, &sw, &w); 758 rb->snprintf(s, sizeof(s), "%d", vscore);
759 rb->lcd_getstringsize(s, &sw, &w);
757#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 760#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
758 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); 761 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
759#else 762#else
760 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s); 763 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 2, s);
761#endif 764#endif
762 rb->lcd_update_rect(0,0,LCD_WIDTH,w+2); 765 rb->lcd_update_rect(0,0,LCD_WIDTH,w+2);
763 } else { 766 } else {
764 if (count==0) count=*rb->current_tick+HZ*secs; 767 if (count==0)
765 if (*rb->current_tick>=count) 768 count=*rb->current_tick+HZ*secs;
766 done=true; 769 if (*rb->current_tick>=count)
767 } 770 done=true;
768 rb->yield(); 771 }
769 } 772 rb->yield();
770 773 }
774
771} 775}
772 776
773 777
@@ -777,10 +781,10 @@ int game_menu(int when)
777{ 781{
778 int button,cur=0; 782 int button,cur=0;
779 char str[10]; 783 char str[10];
780 rb->lcd_clear_display(); 784 rb->lcd_clear_display();
781 #if (LCD_WIDTH != 112) && (LCD_HEIGHT != 64) 785#if (LCD_WIDTH != 112) && (LCD_HEIGHT != 64)
782 rb->lcd_bitmap(brickmania_menu_bg,0,0,BMPWIDTH_menu,BMPHEIGHT_menu); 786 rb->lcd_bitmap(brickmania_menu_bg,0,0,BMPWIDTH_menu,BMPHEIGHT_menu);
783 #endif 787#endif
784 while (true) { 788 while (true) {
785 for(i=0;i<MENU_LENGTH;i++) { 789 for(i=0;i<MENU_LENGTH;i++) {
786 if (cur==0) 790 if (cur==0)
@@ -838,7 +842,7 @@ int game_menu(int when)
838 rb->lcd_update(); 842 rb->lcd_update();
839 843
840 button = rb->button_get(true); 844 button = rb->button_get(true);
841 switch(button){ 845 switch(button) {
842 case UP: 846 case UP:
843 if (cur==0) 847 if (cur==0)
844 cur = MENU_LENGTH-1; 848 cur = MENU_LENGTH-1;
@@ -846,7 +850,7 @@ int game_menu(int when)
846 cur--; 850 cur--;
847 if (when==0 && cur==1) { 851 if (when==0 && cur==1) {
848 cur = 0; 852 cur = 0;
849 }; 853 }
850 break; 854 break;
851 855
852 case DOWN: 856 case DOWN:
@@ -856,7 +860,7 @@ int game_menu(int when)
856 cur++; 860 cur++;
857 if (when==0 && cur==1) { 861 if (when==0 && cur==1) {
858 cur=2; 862 cur=2;
859 }; 863 }
860 break; 864 break;
861 865
862 case RIGHT: 866 case RIGHT:
@@ -868,15 +872,15 @@ int game_menu(int when)
868 } else if (cur==1 && when==1) { 872 } else if (cur==1 && when==1) {
869 return 1; 873 return 1;
870 } else if (cur==2) { 874 } else if (cur==2) {
871 return 2; 875 return 2;
872 } else if (cur==3) { 876 } else if (cur==3) {
873 return 3; 877 return 3;
874 } 878 }
875 break; 879 break;
876 case QUIT: 880 case QUIT:
877 return 3; 881 return 3;
878 break; 882 break;
879 883
880 default: 884 default:
881 if(rb->default_event_handler(button) == SYS_USB_CONNECTED) 885 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
882 return 3; 886 return 3;
@@ -896,14 +900,14 @@ int help(int when)
896 int maxY=160; 900 int maxY=160;
897 int maxX=210; 901 int maxX=210;
898 902
899 while(true){ 903 while(true) {
900#ifdef HAVE_LCD_COLOR 904#ifdef HAVE_LCD_COLOR
901 rb->lcd_set_background(LCD_BLACK); 905 rb->lcd_set_background(LCD_BLACK);
902 rb->lcd_clear_display(); 906 rb->lcd_clear_display();
903 rb->lcd_set_background(LCD_BLACK); 907 rb->lcd_set_background(LCD_BLACK);
904 rb->lcd_set_foreground(LCD_WHITE); 908 rb->lcd_set_foreground(LCD_WHITE);
905#else 909#else
906 rb->lcd_clear_display(); 910 rb->lcd_clear_display();
907#endif 911#endif
908 912
909 rb->lcd_getstringsize("BrickMania", &w, &h); 913 rb->lcd_getstringsize("BrickMania", &w, &h);
@@ -916,39 +920,50 @@ int help(int when)
916#else 920#else
917 rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); 921 rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim");
918#endif 922#endif
919 rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset,"destroy all the bricks by bouncing"); 923 rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset,
920 rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset,"the ball of them using the paddle."); 924 "destroy all the bricks by bouncing");
925 rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset,
926 "the ball of them using the paddle.");
921#ifdef HAVE_LCD_COLOR 927#ifdef HAVE_LCD_COLOR
922 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); 928 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
923 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); 929 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls");
924 rb->lcd_set_foreground(LCD_WHITE); 930 rb->lcd_set_foreground(LCD_WHITE);
925#else 931#else
926 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); 932 rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls");
927 #endif 933#endif
928 rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); 934 rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle");
929#if CONFIG_KEYPAD == ONDIO_PAD 935#if CONFIG_KEYPAD == ONDIO_PAD
930 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,"MENU Releases the ball/Fire!"); 936 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
937 "MENU Releases the ball/Fire!");
931#elif CONFIG_KEYPAD == RECORDER_PAD 938#elif CONFIG_KEYPAD == RECORDER_PAD
932 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,"PLAY Releases the ball/Fire!"); 939 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
940 "PLAY Releases the ball/Fire!");
933#elif CONFIG_KEYPAD == IRIVER_H300_PAD 941#elif CONFIG_KEYPAD == IRIVER_H300_PAD
934 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,"NAVI Releases the ball/Fire!"); 942 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
943 "NAVI Releases the ball/Fire!");
935#else 944#else
936 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,"SELECT Releases the ball/Fire!"); 945 rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,
946 "SELECT Releases the ball/Fire!");
937#endif 947#endif
938 rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset,"STOP Opens menu/Quit"); 948 rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit");
939#ifdef HAVE_LCD_COLOR 949#ifdef HAVE_LCD_COLOR
940 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); 950 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
941 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset,"Specials"); 951 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials");
942 rb->lcd_set_foreground(LCD_WHITE); 952 rb->lcd_set_foreground(LCD_WHITE);
943#else 953#else
944 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset,"Specials"); 954 rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials");
945#endif 955#endif
946 rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset,"N Normal:returns paddle to normal"); 956 rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset,
947 rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset,"D DIE!:loses a life"); 957 "N Normal:returns paddle to normal");
948 rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset,"L Life:gains a life/power up"); 958 rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life");
949 rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset,"F Fire:allows you to shoot bricks"); 959 rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset,
950 rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset,"G Glue:ball sticks to paddle"); 960 "L Life:gains a life/power up");
951 rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset,"B Ball:Generates Another Ball"); 961 rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset,
962 "F Fire:allows you to shoot bricks");
963 rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset,
964 "G Glue:ball sticks to paddle");
965 rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset,
966 "B Ball:Generates Another Ball");
952 rb->lcd_update(); 967 rb->lcd_update();
953 968
954 button=rb->button_get(true); 969 button=rb->button_get(true);
@@ -964,7 +979,8 @@ int help(int when)
964 con_game=1; 979 con_game=1;
965 break; 980 break;
966 case 2: 981 case 2:
967 if (help(when)==1) return 1; 982 if (help(when)==1)
983 return 1;
968 break; 984 break;
969 case 3: 985 case 3:
970 return 1; 986 return 1;
@@ -972,27 +988,27 @@ int help(int when)
972 } 988 }
973 return 0; 989 return 0;
974 break; 990 break;
975 case LEFT: 991 case LEFT:
976 case LEFT | BUTTON_REPEAT: 992 case LEFT | BUTTON_REPEAT:
977 if( xoffset<0) 993 if( xoffset<0)
978 xoffset+=2; 994 xoffset+=2;
979 break; 995 break;
980 case RIGHT: 996 case RIGHT:
981 case RIGHT | BUTTON_REPEAT: 997 case RIGHT | BUTTON_REPEAT:
982 if(xoffset+maxX > LCD_WIDTH) 998 if(xoffset+maxX > LCD_WIDTH)
983 xoffset-=2; 999 xoffset-=2;
984 break; 1000 break;
985 case UP: 1001 case UP:
986 case UP | BUTTON_REPEAT: 1002 case UP | BUTTON_REPEAT:
987 if(yoffset <0) 1003 if(yoffset <0)
988 yoffset+=2; 1004 yoffset+=2;
989 break; 1005 break;
990 case DOWN: 1006 case DOWN:
991 case DOWN | BUTTON_REPEAT: 1007 case DOWN | BUTTON_REPEAT:
992 if(yoffset+maxY > LCD_HEIGHT) 1008 if(yoffset+maxY > LCD_HEIGHT)
993 yoffset-=2; 1009 yoffset-=2;
994 break; 1010 break;
995 1011
996 default: 1012 default:
997 if(rb->default_event_handler(button) == SYS_USB_CONNECTED) 1013 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
998 return 1; 1014 return 1;
@@ -1002,7 +1018,7 @@ int help(int when)
1002 return 0; 1018 return 0;
1003} 1019}
1004 1020
1005int pad_check(int ballxc, int mode, int pon ,int ballnum) 1021int pad_check(int ballxc, int mode, int pon ,int ballnum)
1006{ 1022{
1007 /* pon: positive(1) or negative(0) */ 1023 /* pon: positive(1) or negative(0) */
1008 1024
@@ -1029,18 +1045,19 @@ int fire_space(void)
1029 return 0; 1045 return 0;
1030} 1046}
1031 1047
1032int game_loop(void){ 1048int game_loop(void)
1049{
1033 int j,i,k,bricky,brickx; 1050 int j,i,k,bricky,brickx;
1034 char s[30]; 1051 char s[30];
1035 int sec_count=0,num_count=10; 1052 int sec_count=0,num_count=10;
1036 int end; 1053 int end;
1037 1054
1038 rb->srand( *rb->current_tick ); 1055 rb->srand( *rb->current_tick );
1039 1056
1040 configfile_init(rb); 1057 configfile_init(rb);
1041 configfile_load(HIGH_SCORE,config,1,0); 1058 configfile_load(HIGH_SCORE,config,1,0);
1042 1059
1043 switch(game_menu(0)){ 1060 switch(game_menu(0)) {
1044 case 0: 1061 case 0:
1045 cur_level = 0; 1062 cur_level = 0;
1046 life = 2; 1063 life = 2;
@@ -1069,22 +1086,22 @@ int game_loop(void){
1069 rb->lcd_set_background(LCD_BLACK); 1086 rb->lcd_set_background(LCD_BLACK);
1070 rb->lcd_set_foreground(LCD_WHITE); 1087 rb->lcd_set_foreground(LCD_WHITE);
1071#else 1088#else
1072 rb->lcd_clear_display(); 1089 rb->lcd_clear_display();
1073#endif 1090#endif
1074 1091
1075 if (flip_sides) { 1092 if (flip_sides) {
1076 if (*rb->current_tick>=sec_count){ 1093 if (*rb->current_tick>=sec_count) {
1077 sec_count=*rb->current_tick+HZ; 1094 sec_count=*rb->current_tick+HZ;
1078 if (num_count!=0) 1095 if (num_count!=0)
1079 num_count--; 1096 num_count--;
1080 else 1097 else
1081 flip_sides=false; 1098 flip_sides=false;
1082 } 1099 }
1083 rb->snprintf(s, sizeof(s), "%d", num_count); 1100 rb->snprintf(s, sizeof(s), "%d", num_count);
1084 rb->lcd_getstringsize(s, &sw, NULL); 1101 rb->lcd_getstringsize(s, &sw, NULL);
1085 rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_flipsides, s); 1102 rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_flipsides, s);
1086 } 1103 }
1087 1104
1088 /* write life num */ 1105 /* write life num */
1089#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 1106#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1090 rb->snprintf(s, sizeof(s), "L:%d", life); 1107 rb->snprintf(s, sizeof(s), "L:%d", life);
@@ -1093,7 +1110,7 @@ int game_loop(void){
1093 rb->snprintf(s, sizeof(s), "Life: %d", life); 1110 rb->snprintf(s, sizeof(s), "Life: %d", life);
1094 rb->lcd_putsxy(2, 2, s); 1111 rb->lcd_putsxy(2, 2, s);
1095#endif 1112#endif
1096 1113
1097#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 1114#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1098 rb->snprintf(s, sizeof(s), "L%d", cur_level+1); 1115 rb->snprintf(s, sizeof(s), "L%d", cur_level+1);
1099 rb->lcd_getstringsize(s, &sw, NULL); 1116 rb->lcd_getstringsize(s, &sw, NULL);
@@ -1130,9 +1147,11 @@ int game_loop(void){
1130 1147
1131 /* draw the ball */ 1148 /* draw the ball */
1132 for(i=0;i<used_balls;i++) 1149 for(i=0;i<used_balls;i++)
1133 rb->lcd_bitmap(brickmania_ball,ball[i].pos_x, ball[i].pos_y, BALL, BALL); 1150 rb->lcd_bitmap(brickmania_ball,ball[i].pos_x, ball[i].pos_y,
1151 BALL, BALL);
1134 1152
1135 if (brick_on_board==0) brick_on_board--; 1153 if (brick_on_board==0)
1154 brick_on_board--;
1136 1155
1137 /* if the pad is fire */ 1156 /* if the pad is fire */
1138 for(i=0;i<=30;i++) { 1157 for(i=0;i<=30;i++) {
@@ -1150,14 +1169,23 @@ int game_loop(void){
1150 if (brick[i*10+j].poweruse==2) { 1169 if (brick[i*10+j].poweruse==2) {
1151 if (con_game!=1) 1170 if (con_game!=1)
1152 brick[i*10+j].powertop+=2; 1171 brick[i*10+j].powertop+=2;
1153 rb->lcd_bitmap_part(brickmania_powerups,0, 1172 rb->lcd_bitmap_part(brickmania_powerups,0,
1154 BMPHEIGHT_powerup*brick[i*10+j].power, 1173 BMPHEIGHT_powerup*brick[i*10+j
1155 BMPWIDTH_powerup,LEFTMARGIN+j*BRICK_WIDTH+(BRICK_WIDTH/2-BMPWIDTH_powerup/2), 1174 ].power,
1156 brick[i*10+j].powertop, BMPWIDTH_powerup, BMPHEIGHT_powerup); 1175 BMPWIDTH_powerup,
1157 } 1176 LEFTMARGIN+j*BRICK_WIDTH+
1177 (BRICK_WIDTH/2-
1178 BMPWIDTH_powerup/2),
1179 brick[i*10+j].powertop,
1180 BMPWIDTH_powerup,
1181 BMPHEIGHT_powerup);
1158 } 1182 }
1183 }
1159 1184
1160 if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 && pad_pos_x+PAD_WIDTH>LEFTMARGIN+j*BRICK_WIDTH+5) && brick[i*10+j].powertop+6>=PAD_POS_Y && brick[i*10+j].poweruse==2) { 1185 if ((pad_pos_x<LEFTMARGIN+j*BRICK_WIDTH+5 &&
1186 pad_pos_x+PAD_WIDTH>LEFTMARGIN+j*BRICK_WIDTH+5) &&
1187 brick[i*10+j].powertop+6>=PAD_POS_Y &&
1188 brick[i*10+j].poweruse==2) {
1161 switch(brick[i*10+j].power) { 1189 switch(brick[i*10+j].power) {
1162 case 0: 1190 case 0:
1163 life++; 1191 life++;
@@ -1177,159 +1205,250 @@ int game_loop(void){
1177 case 3: 1205 case 3:
1178 score+=47; 1206 score+=47;
1179 pad_type=2; 1207 pad_type=2;
1180 for(k=0;k<used_balls;k++) 1208 for(k=0;k<used_balls;k++)
1181 ball[k].glue=false; 1209 ball[k].glue=false;
1182 break; 1210 break;
1183 case 4: 1211 case 4:
1184 score+=23; 1212 score+=23;
1185 pad_type=0; 1213 pad_type=0;
1186 for(k=0;k<used_balls;k++) 1214 for(k=0;k<used_balls;k++)
1187 ball[k].glue=false; 1215 ball[k].glue=false;
1188 flip_sides=false; 1216 flip_sides=false;
1189 break; 1217 break;
1190 case 5: 1218 case 5:
1191 score+=23; 1219 score+=23;
1192 sec_count=*rb->current_tick+HZ; 1220 sec_count=*rb->current_tick+HZ;
1193 num_count=10; 1221 num_count=10;
1194 flip_sides=!flip_sides; 1222 flip_sides=!flip_sides;
1195 break; 1223 break;
1196 case 6: 1224 case 6:
1197 score+=23; 1225 score+=23;
1198 used_balls++; 1226 used_balls++;
1199 ball[used_balls-1].x= rb->rand()%1 == 0 ? -1 : 1; 1227 ball[used_balls-1].x= rb->rand()%1 == 0 ?
1228 -1 : 1;
1200 ball[used_balls-1].y= -4; 1229 ball[used_balls-1].y= -4;
1201 break; 1230 break;
1202 } 1231 }
1203 brick[i*10+j].poweruse=1; 1232 brick[i*10+j].poweruse=1;
1204 } 1233 }
1205 1234
1206 if (brick[i*10+j].powertop>PAD_POS_Y) 1235 if (brick[i*10+j].powertop>PAD_POS_Y)
1207 brick[i*10+j].poweruse=1; 1236 brick[i*10+j].poweruse=1;
1208 1237
1209 brickx=LEFTMARGIN+j*BRICK_WIDTH; 1238 brickx=LEFTMARGIN+j*BRICK_WIDTH;
1210 bricky=TOPMARGIN+i*BRICK_HEIGHT; 1239 bricky=TOPMARGIN+i*BRICK_HEIGHT;
1211 if (pad_type==2) { 1240 if (pad_type==2) {
1212 for (k=0;k<=30;k++) { 1241 for (k=0;k<=30;k++) {
1213 if (fire[k].top+7>0) { 1242 if (fire[k].top+7>0) {
1214 if (brick[i*10+j].used==1 && (fire[k].left+1 >= brickx && fire[k].left+1 <= brickx+BRICK_WIDTH) && (bricky+BRICK_HEIGHT>fire[k].top)){ 1243 if (brick[i*10+j].used==1 &&
1215 score+=13; 1244 (fire[k].left+1 >= brickx &&
1216 fire[k].top=-16; 1245 fire[k].left+1 <= brickx+BRICK_WIDTH) &&
1217 if (brick[i*10+j].hits > 0){ 1246 (bricky+BRICK_HEIGHT>fire[k].top)) {
1218 brick[i*10+j].hits--; 1247 score+=13;
1219 brick[i*10+j].hiteffect++; 1248 fire[k].top=-16;
1220 score+=3; 1249 if (brick[i*10+j].hits > 0) {
1221 } 1250 brick[i*10+j].hits--;
1222 else { 1251 brick[i*10+j].hiteffect++;
1223 brick[i*10+j].used=0; 1252 score+=3;
1224 if (brick[i*10+j].power!=10) brick[i*10+j].poweruse=2; 1253 }
1254 else {
1255 brick[i*10+j].used=0;
1256 if (brick[i*10+j].power!=10)
1257 brick[i*10+j].poweruse=2;
1225 brick_on_board--; 1258 brick_on_board--;
1259 }
1226 } 1260 }
1227 } 1261 }
1228 } 1262 }
1229 } 1263 }
1230 } 1264
1231 1265 if (brick[i*10+j].used==1) {
1232 if (brick[i*10+j].used==1){ 1266 rb->lcd_bitmap_part(brickmania_bricks,0,
1233 rb->lcd_bitmap_part(brickmania_bricks,0,BRICK_HEIGHT*brick[i*10+j].color,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, TOPMARGIN+i*BRICK_HEIGHT, BRICK_WIDTH, BRICK_HEIGHT); 1267 BRICK_HEIGHT*brick[i*10+j].color,
1268 BRICK_WIDTH,
1269 LEFTMARGIN+j*BRICK_WIDTH,
1270 TOPMARGIN+i*BRICK_HEIGHT,
1271 BRICK_WIDTH, BRICK_HEIGHT);
1234#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ 1272#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1235 if (brick[i*10+j].hiteffect>0) 1273 if (brick[i*10+j].hiteffect>0)
1236 rb->lcd_bitmap_transparent_part(brickmania_break,0,BRICK_HEIGHT*brick[i*10+j].hiteffect,BRICK_WIDTH,LEFTMARGIN+j*BRICK_WIDTH, TOPMARGIN+i*BRICK_HEIGHT, BRICK_WIDTH, BRICK_HEIGHT); 1274 rb->lcd_bitmap_transparent_part(brickmania_break,
1275 0,
1276 BRICK_HEIGHT*brick[i*10+j].hiteffect,
1277 BRICK_WIDTH,
1278 LEFTMARGIN+j*BRICK_WIDTH,
1279 TOPMARGIN+i*BRICK_HEIGHT,
1280 BRICK_WIDTH,
1281 BRICK_HEIGHT);
1237#endif 1282#endif
1238 } 1283 }
1239
1240 for(k=0;k<used_balls;k++) {
1241 if (ball[k].pos_y <100) {
1242 if (brick[i*10+j].used==1) {
1243 if ((ball[k].pos_x+ball[k].x+HALFBALL >= brickx && ball[k].pos_x+ball[k].x+HALFBALL <= 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)){
1244 ball[k].tempy=bricky-ball[k].pos_y-BALL;
1245 } else if ((ball[k].pos_x+ball[k].x+HALFBALL >= brickx && ball[k].pos_x+ball[k].x+HALFBALL <= 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)){
1246 ball[k].tempy=-(ball[k].pos_y-(bricky+BRICK_HEIGHT));
1247 }
1248 1284
1249 if ((ball[k].pos_y+HALFBALL >= bricky && ball[k].pos_y+HALFBALL <= 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)) { 1285 for(k=0;k<used_balls;k++) {
1250 ball[k].tempx=brickx-ball[k].pos_x-BALL; 1286 if (ball[k].pos_y <100) {
1251 } else if ((ball[k].pos_y+ball[k].y+HALFBALL >= bricky && ball[k].pos_y+ball[k].y+HALFBALL <= 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)) { 1287 if (brick[i*10+j].used==1) {
1252 ball[k].tempx=-(ball[k].pos_x-(brickx+BRICK_WIDTH)); 1288 if ((ball[k].pos_x+ball[k].x+HALFBALL >=
1253 } 1289 brickx &&
1290 ball[k].pos_x+ball[k].x+HALFBALL <=
1291 brickx+BRICK_WIDTH) &&
1292 ((bricky-4<ball[k].pos_y+BALL &&
1293 bricky>ball[k].pos_y+BALL) ||
1294 (bricky+4>ball[k].pos_y+BALL+BALL &&
1295 bricky<ball[k].pos_y+BALL+BALL)) &&
1296 (ball[k].y >0)) {
1297 ball[k].tempy=bricky-ball[k].pos_y-BALL;
1298 }
1299 else if ((ball[k].pos_x+ball[k].x+HALFBALL >=
1300 brickx &&
1301 ball[k].pos_x+ball[k].x+HALFBALL <=
1302 brickx+BRICK_WIDTH) &&
1303 ((bricky+BRICK_HEIGHT+4>ball[k].pos_y &&
1304 bricky+BRICK_HEIGHT<ball[k].pos_y) ||
1305 (bricky+BRICK_HEIGHT-4<ball[k].pos_y-BALL &&
1306 bricky+BRICK_HEIGHT>ball[k].pos_y-BALL)) &&
1307 (ball[k].y <0)) {
1308 ball[k].tempy=
1309 -(ball[k].pos_y-(bricky+BRICK_HEIGHT));
1310 }
1254 1311
1255 if ((ball[k].pos_x+HALFBALL >= brickx && ball[k].pos_x+HALFBALL <= 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 */ 1312 if ((ball[k].pos_y+HALFBALL >=
1256 if (brick[i*10+j].hits > 0){ 1313 bricky &&
1257 brick[i*10+j].hits--; 1314 ball[k].pos_y+HALFBALL <=
1258 brick[i*10+j].hiteffect++; 1315 bricky+BRICK_HEIGHT) &&
1259 score+=2; 1316 ((brickx-4<ball[k].pos_x+BALL &&
1260 } 1317 brickx>ball[k].pos_x+BALL) ||
1261 else { 1318 (brickx+4>ball[k].pos_x+BALL+BALL &&
1262 brick[i*10+j].used=0; 1319 brickx<ball[k].pos_x+BALL+BALL)) &&
1263 if (brick[i*10+j].power!=10) 1320 (ball[k].x >0)) {
1264 brick[i*10+j].poweruse=2; 1321 ball[k].tempx=brickx-ball[k].pos_x-BALL;
1265 } 1322 }
1266 1323 else if ((ball[k].pos_y+ball[k].y+HALFBALL >=
1267 ball[k].y = ball[k].y*-1; 1324 bricky &&
1268 } else if ((ball[k].pos_x+HALFBALL >= brickx && ball[k].pos_x+HALFBALL <= 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 */ 1325 ball[k].pos_y+ball[k].y+HALFBALL <=
1269 if (brick[i*10+j].hits > 0){ 1326 bricky+BRICK_HEIGHT) &&
1270 brick[i*10+j].hits--; 1327 ((brickx+BRICK_WIDTH+4>ball[k].pos_x &&
1271 brick[i*10+j].hiteffect++; 1328 brickx+BRICK_WIDTH<ball[k].pos_x) ||
1272 score+=2; 1329 (brickx+BRICK_WIDTH-4<ball[k].pos_x-
1273 } 1330 BALL &&
1274 else { 1331 brickx+BRICK_WIDTH>ball[k].pos_x-
1275 brick[i*10+j].used=0; 1332 BALL)) && (ball[k].x <0)) {
1276 if (brick[i*10+j].power!=10) 1333 ball[k].tempx=
1277 brick[i*10+j].poweruse=2; 1334 -(ball[k].pos_x-(brickx+BRICK_WIDTH));
1278 } 1335 }
1279
1280 ball[k].y = ball[k].y*-1;
1281 }
1282 1336
1283 if ((ball[k].pos_y+HALFBALL >= bricky && ball[k].pos_y+HALFBALL <= 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 */ 1337 if ((ball[k].pos_x+HALFBALL >= brickx &&
1284 if (brick[i*10+j].hits > 0){ 1338 ball[k].pos_x+HALFBALL <=
1285 brick[i*10+j].hits--; 1339 brickx+BRICK_WIDTH) &&
1286 brick[i*10+j].hiteffect++; 1340 ((bricky+BRICK_HEIGHT==ball[k].pos_y) ||
1287 score+=2; 1341 (bricky+BRICK_HEIGHT-6<=ball[k].pos_y &&
1288 } 1342 bricky+BRICK_HEIGHT>ball[k].pos_y)) &&
1289 else { 1343 (ball[k].y <0)) { /* bottom line */
1290 brick[i*10+j].used=0; 1344 if (brick[i*10+j].hits > 0) {
1291 if (brick[i*10+j].power!=10) 1345 brick[i*10+j].hits--;
1292 brick[i*10+j].poweruse=2; 1346 brick[i*10+j].hiteffect++;
1293 } 1347 score+=2;
1294 ball[k].x = ball[k].x*-1; 1348 }
1295 1349 else {
1296 } else if ((ball[k].pos_y+HALFBALL >= bricky && ball[k].pos_y+HALFBALL <= 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 */ 1350 brick[i*10+j].used=0;
1297 if (brick[i*10+j].hits > 0){ 1351 if (brick[i*10+j].power!=10)
1298 brick[i*10+j].hits--; 1352 brick[i*10+j].poweruse=2;
1299 brick[i*10+j].hiteffect++; 1353 }
1300 score+=2; 1354
1301 } 1355 ball[k].y = ball[k].y*-1;
1302 else { 1356 }
1303 brick[i*10+j].used=0; 1357 else if ((ball[k].pos_x+HALFBALL >= brickx &&
1304 if (brick[i*10+j].power!=10) 1358 ball[k].pos_x+HALFBALL <=
1305 brick[i*10+j].poweruse=2; 1359 brickx+BRICK_WIDTH) &&
1360 ((bricky==ball[k].pos_y+BALL) ||
1361 (bricky+6>=ball[k].pos_y+BALL &&
1362 bricky<ball[k].pos_y+BALL)) &&
1363 (ball[k].y >0)) { /* top line */
1364 if (brick[i*10+j].hits > 0) {
1365 brick[i*10+j].hits--;
1366 brick[i*10+j].hiteffect++;
1367 score+=2;
1368 }
1369 else {
1370 brick[i*10+j].used=0;
1371 if (brick[i*10+j].power!=10)
1372 brick[i*10+j].poweruse=2;
1373 }
1374
1375 ball[k].y = ball[k].y*-1;
1306 } 1376 }
1307
1308 ball[k].x = ball[k].x*-1;
1309 }
1310 1377
1311 if (brick[i*10+j].used==0){ 1378 if ((ball[k].pos_y+HALFBALL >= bricky &&
1312 brick_on_board--; 1379 ball[k].pos_y+HALFBALL <=
1313 score+=8; 1380 bricky+BRICK_HEIGHT) &&
1381 ((brickx==ball[k].pos_x+BALL) ||
1382 (brickx+6>=ball[k].pos_x+BALL &&
1383 brickx<ball[k].pos_x+BALL)) &&
1384 (ball[k].x > 0)) { /* left line */
1385 if (brick[i*10+j].hits > 0) {
1386 brick[i*10+j].hits--;
1387 brick[i*10+j].hiteffect++;
1388 score+=2;
1389 }
1390 else {
1391 brick[i*10+j].used=0;
1392 if (brick[i*10+j].power!=10)
1393 brick[i*10+j].poweruse=2;
1394 }
1395 ball[k].x = ball[k].x*-1;
1396
1397 }
1398 else if ((ball[k].pos_y+HALFBALL >= bricky &&
1399 ball[k].pos_y+HALFBALL <=
1400 bricky+BRICK_HEIGHT) &&
1401 ((brickx+BRICK_WIDTH==
1402 ball[k].pos_x) ||
1403 (brickx+BRICK_WIDTH-6<=
1404 ball[k].pos_x &&
1405 brickx+BRICK_WIDTH>
1406 ball[k].pos_x)) &&
1407 (ball[k].x < 0)) { /* Right line */
1408 if (brick[i*10+j].hits > 0) {
1409 brick[i*10+j].hits--;
1410 brick[i*10+j].hiteffect++;
1411 score+=2;
1412 }
1413 else {
1414 brick[i*10+j].used=0;
1415 if (brick[i*10+j].power!=10)
1416 brick[i*10+j].poweruse=2;
1417 }
1418
1419 ball[k].x = ball[k].x*-1;
1420 }
1421
1422 if (brick[i*10+j].used==0) {
1423 brick_on_board--;
1424 score+=8;
1425 }
1314 } 1426 }
1315 } 1427 }
1316 } 1428 } /* for k */
1317 } /* for k */
1318 } /* for j */ 1429 } /* for j */
1319 } /* for i */ 1430 } /* for i */
1320 1431
1321 /* draw the pad */ 1432 /* draw the pad */
1322 rb->lcd_bitmap_part(brickmania_pads,0,pad_type*PAD_HEIGHT,PAD_WIDTH,pad_pos_x, PAD_POS_Y, PAD_WIDTH, PAD_HEIGHT); 1433 rb->lcd_bitmap_part(brickmania_pads,0,pad_type*PAD_HEIGHT,
1323 1434 PAD_WIDTH,pad_pos_x, PAD_POS_Y, PAD_WIDTH,
1435 PAD_HEIGHT);
1436
1324 for(k=0;k<used_balls;k++) { 1437 for(k=0;k<used_balls;k++) {
1325 1438
1326 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)) 1439 if ((ball[k].pos_x >= pad_pos_x &&
1440 ball[k].pos_x <= pad_pos_x+PAD_WIDTH) &&
1441 (PAD_POS_Y-4<ball[k].pos_y+BALL &&
1442 PAD_POS_Y>ball[k].pos_y+BALL) && (ball[k].y >0))
1327 ball[k].tempy=PAD_POS_Y-ball[k].pos_y-BALL; 1443 ball[k].tempy=PAD_POS_Y-ball[k].pos_y-BALL;
1328 else if ((4>ball[k].pos_y && 0<ball[k].pos_y) && (ball[k].y <0)) 1444 else if ((4>ball[k].pos_y && 0<ball[k].pos_y) &&
1445 (ball[k].y <0))
1329 ball[k].tempy=-ball[k].pos_y; 1446 ball[k].tempy=-ball[k].pos_y;
1330 if ((LCD_WIDTH-4<ball[k].pos_x+BALL && LCD_WIDTH>ball[k].pos_x+BALL) && (ball[k].x >0)) 1447 if ((LCD_WIDTH-4<ball[k].pos_x+BALL &&
1448 LCD_WIDTH>ball[k].pos_x+BALL) && (ball[k].x >0))
1331 ball[k].tempx=LCD_WIDTH-ball[k].pos_x-BALL; 1449 ball[k].tempx=LCD_WIDTH-ball[k].pos_x-BALL;
1332 else if ((4>ball[k].pos_x && 0<ball[k].pos_x) && (ball[k].x <0)) 1450 else if ((4>ball[k].pos_x && 0<ball[k].pos_x) &&
1451 (ball[k].x <0))
1333 ball[k].tempx=-ball[k].pos_x; 1452 ball[k].tempx=-ball[k].pos_x;
1334 1453
1335 /* top line */ 1454 /* top line */
@@ -1346,278 +1465,338 @@ int game_loop(void){
1346 ball[k].x = ball[used_balls].x; 1465 ball[k].x = ball[used_balls].x;
1347 ball[k].tempx = ball[used_balls].tempx; 1466 ball[k].tempx = ball[used_balls].tempx;
1348 ball[k].glue = ball[used_balls].glue; 1467 ball[k].glue = ball[used_balls].glue;
1349 1468
1350 ball[used_balls].x=0; 1469 ball[used_balls].x=0;
1351 ball[used_balls].y=0; 1470 ball[used_balls].y=0;
1352 ball[used_balls].tempy=0; 1471 ball[used_balls].tempy=0;
1353 ball[used_balls].tempx=0; 1472 ball[used_balls].tempx=0;
1354 ball[used_balls].pos_y=PAD_POS_Y-BALL; 1473 ball[used_balls].pos_y=PAD_POS_Y-BALL;
1355 ball[used_balls].pos_x=pad_pos_x+(PAD_WIDTH/2)-2; 1474 ball[used_balls].pos_x=pad_pos_x+(PAD_WIDTH/2)-2;
1356 1475
1357 k--; 1476 k--;
1358 continue; 1477 continue;
1359 } else { 1478 } else {
1360 life--; 1479 life--;
1361 if (life>=0){ 1480 if (life>=0) {
1362 int_game(0); 1481 int_game(0);
1363 sleep(2); 1482 sleep(2);
1364 } 1483 }
1365 } 1484 }
1366 } 1485 }
1367 1486
1368 /* left line ,right line */ 1487 /* left line ,right line */
1369 if ((ball[k].pos_x <= 0) || (ball[k].pos_x+BALL >= LCD_WIDTH)){ 1488 if ((ball[k].pos_x <= 0) ||
1489 (ball[k].pos_x+BALL >= LCD_WIDTH)) {
1370 ball[k].x = ball[k].x*-1; 1490 ball[k].x = ball[k].x*-1;
1371 ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; 1491 ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL;
1372 } 1492 }
1373
1374 if ((ball[k].pos_y+BALL >= PAD_POS_Y && (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) &&
1375 start_game != 1 && !ball[k].glue) {
1376
1377 if ((ball[k].pos_x+HALFBALL >= pad_pos_x && ball[k].pos_x+HALFBALL <= pad_pos_x+(PAD_WIDTH/2/4)) ||
1378 (ball[k].pos_x +HALFBALL>= pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) && ball[k].pos_x+HALFBALL <= pad_pos_x+PAD_WIDTH)) {
1379
1380 ball[k].y = -2;
1381 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1382 ball[k].x = pad_check(6,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1383
1384 } else if ((ball[k].pos_x+HALFBALL >= pad_pos_x+(PAD_WIDTH/2/4) && ball[k].pos_x+HALFBALL <= pad_pos_x+2*(PAD_WIDTH/2/4)) ||
1385 (ball[k].pos_x+HALFBALL >= pad_pos_x+(PAD_WIDTH-2*(PAD_WIDTH/2/4)) && ball[k].pos_x+HALFBALL <= pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) )) {
1386
1387 ball[k].y = -3;
1388 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1389 ball[k].x = pad_check(4,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1390
1391 } else if ((ball[k].pos_x+HALFBALL >= pad_pos_x+2*(PAD_WIDTH/2/4) && ball[k].pos_x+HALFBALL <= pad_pos_x+3*(PAD_WIDTH/2/4)) ||
1392 (ball[k].pos_x+2 >= pad_pos_x+(PAD_WIDTH-3*(PAD_WIDTH/2/4)) && ball[k].pos_x+2 <= pad_pos_x+ ((PAD_WIDTH/2)-2*(PAD_WIDTH/2/4)) )) {
1393
1394 ball[k].y = -4;
1395 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1396 ball[k].x = pad_check(3,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k);
1397
1398 } else if ((ball[k].pos_x+HALFBALL >= pad_pos_x+3*(PAD_WIDTH/2/4) && ball[k].pos_x+HALFBALL <= pad_pos_x+4*(PAD_WIDTH/2/4)-2) ||
1399 (ball[k].pos_x+2 >= pad_pos_x+(PAD_WIDTH/2+2) && ball[k].pos_x+2 <= pad_pos_x+(PAD_WIDTH-3*(PAD_WIDTH/2/4)) )) {
1400
1401 ball[k].y = -4;
1402 if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH)
1403 ball[k].x = pad_check(2,1,0,k);
1404 1493
1405 } else { 1494 if ((ball[k].pos_y+BALL >= PAD_POS_Y &&
1406 ball[k].y = -4; 1495 (ball[k].pos_x >= pad_pos_x &&
1496 ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) &&
1497 start_game != 1 && !ball[k].glue) {
1498
1499 if ((ball[k].pos_x+HALFBALL >= pad_pos_x &&
1500 ball[k].pos_x+HALFBALL <=
1501 pad_pos_x+(PAD_WIDTH/2/4)) ||
1502 (ball[k].pos_x +HALFBALL>=
1503 pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) &&
1504 ball[k].pos_x+HALFBALL <= pad_pos_x+PAD_WIDTH)) {
1505
1506 ball[k].y = -2;
1507 if (ball[k].pos_x != 0 &&
1508 ball[k].pos_x+BALL!=LCD_WIDTH)
1509 ball[k].x = pad_check(6,0,ball[k].pos_x+2<=
1510 pad_pos_x+(PAD_WIDTH/2)?
1511 0:1,k);
1512
1407 } 1513 }
1408 } 1514 else if ((ball[k].pos_x+HALFBALL >=
1409 1515 pad_pos_x+(PAD_WIDTH/2/4) &&
1410 if (!ball[k].glue) { 1516 ball[k].pos_x+HALFBALL <=
1411 ball[k].pos_x+=ball[k].tempx!=0?ball[k].tempx:ball[k].x; 1517 pad_pos_x+2*(PAD_WIDTH/2/4)) ||
1412 ball[k].pos_y+=ball[k].tempy!=0?ball[k].tempy:ball[k].y; 1518 (ball[k].pos_x+HALFBALL >=
1413 1519 pad_pos_x+(PAD_WIDTH-2*(PAD_WIDTH/2/4)) &&
1414 ball[k].tempy=0; 1520 ball[k].pos_x+HALFBALL <=
1415 ball[k].tempx=0; 1521 pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) )) {
1522
1523 ball[k].y = -3;
1524 if (ball[k].pos_x != 0 &&
1525 ball[k].pos_x+BALL!=LCD_WIDTH)
1526 ball[k].x = pad_check(4,0,ball[k].pos_x+2<=
1527 pad_pos_x+(PAD_WIDTH/2)?
1528 0:1,k);
1529
1416 } 1530 }
1417 1531 else if ((ball[k].pos_x+HALFBALL >=
1418 if (ball[k].pos_y+5 >= PAD_POS_Y && (pad_type==1 && !ball[k].glue) && 1532 pad_pos_x+2*(PAD_WIDTH/2/4) &&
1419 (ball[k].pos_x >= pad_pos_x && ball[k].pos_x <= pad_pos_x+PAD_WIDTH)){ 1533 ball[k].pos_x+HALFBALL <=
1420 ball[k].y=0; 1534 pad_pos_x+3*(PAD_WIDTH/2/4)) ||
1421 ball[k].pos_y=PAD_POS_Y-BALL; 1535 (ball[k].pos_x+2 >=
1422 ball[k].glue=true; 1536 pad_pos_x+(PAD_WIDTH-3*(PAD_WIDTH/2/4)) &&
1537 ball[k].pos_x+2 <=
1538 pad_pos_x+ ((PAD_WIDTH/2)-2*(PAD_WIDTH/2/4)) )) {
1539
1540 ball[k].y = -4;
1541 if (ball[k].pos_x != 0 &&
1542 ball[k].pos_x+BALL!=LCD_WIDTH)
1543 ball[k].x = pad_check(3,0,ball[k].pos_x+2<=
1544 pad_pos_x+(PAD_WIDTH/2)?
1545 0:1,k);
1546
1423 } 1547 }
1424 } /* for k */ 1548 else if ((ball[k].pos_x+HALFBALL >=
1425 1549 pad_pos_x+3*(PAD_WIDTH/2/4) &&
1426 rb->lcd_update(); 1550 ball[k].pos_x+HALFBALL <=
1551 pad_pos_x+4*(PAD_WIDTH/2/4)-2) ||
1552 (ball[k].pos_x+2 >= pad_pos_x+(PAD_WIDTH/2+2) &&
1553 ball[k].pos_x+2 <=
1554 pad_pos_x+(PAD_WIDTH-3*(PAD_WIDTH/2/4)) )) {
1555
1556 ball[k].y = -4;
1557 if (ball[k].pos_x != 0 &&
1558 ball[k].pos_x+BALL!=LCD_WIDTH)
1559 ball[k].x = pad_check(2,1,0,k);
1427 1560
1428 if (brick_on_board < 0) { 1561 }
1429 if (cur_level+1<levels_num) { 1562 else {
1430 cur_level++; 1563 ball[k].y = -4;
1431 score+=100; 1564 }
1432 int_game(1); 1565 }
1433 sleep(2); 1566
1434 } else { 1567 if (!ball[k].glue) {
1435 rb->lcd_getstringsize("Congratulations!", &sw, NULL); 1568 ball[k].pos_x+=ball[k].tempx!=0?ball[k].tempx:ball[k].x;
1436 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_congrats, "Congratulations!"); 1569 ball[k].pos_y+=ball[k].tempy!=0?ball[k].tempy:ball[k].y;
1570
1571 ball[k].tempy=0;
1572 ball[k].tempx=0;
1573 }
1574
1575 if (ball[k].pos_y+5 >= PAD_POS_Y &&
1576 (pad_type==1 && !ball[k].glue) &&
1577 (ball[k].pos_x >= pad_pos_x &&
1578 ball[k].pos_x <= pad_pos_x+PAD_WIDTH)) {
1579 ball[k].y=0;
1580 ball[k].pos_y=PAD_POS_Y-BALL;
1581 ball[k].glue=true;
1582 }
1583 } /* for k */
1584
1585 rb->lcd_update();
1586
1587 if (brick_on_board < 0) {
1588 if (cur_level+1<levels_num) {
1589 cur_level++;
1590 score+=100;
1591 int_game(1);
1592 sleep(2);
1593 }
1594 else {
1595 rb->lcd_getstringsize("Congratulations!", &sw, NULL);
1596 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_congrats,
1597 "Congratulations!");
1437#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 1598#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1438 rb->lcd_getstringsize("No more levels", &sw, NULL); 1599 rb->lcd_getstringsize("No more levels", &sw, NULL);
1439 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_finsh, "No more levels"); 1600 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_finsh,
1601 "No more levels");
1440#else 1602#else
1441 rb->lcd_getstringsize("You have finished the game!", &sw, NULL); 1603 rb->lcd_getstringsize("You have finished the game!",
1442 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_finsh, "You have finished the game!"); 1604 &sw, NULL);
1605 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_finsh,
1606 "You have finished the game!");
1443#endif 1607#endif
1444 vscore=score; 1608 vscore=score;
1445 rb->lcd_update(); 1609 rb->lcd_update();
1446 if (score>highscore) { 1610 if (score>highscore) {
1447 sleep(2); 1611 sleep(2);
1448 highscore=score; 1612 highscore=score;
1449 rb->splash(HZ*2,true,"New High Score"); 1613 rb->splash(HZ*2,true,"New High Score");
1450 } else { 1614 }
1451 sleep(3); 1615 else {
1616 sleep(3);
1617 }
1618
1619 switch(game_menu(0)) {
1620 case 0:
1621 life=2;
1622 cur_level=0;
1623 int_game(1);
1624 break;
1625 case 1:
1626 con_game=1;
1627 break;
1628 case 2:
1629 if (help(0)==1) return 1;
1630 break;
1631 case 3:
1632 return 1;
1633 break;
1634 }
1635 }
1636 }
1637
1638 int move_button,button;
1639 int button_right,button_left;
1640 button=rb->button_get(false);
1641 move_button=rb->button_status();
1642
1643 button_right=((move_button & RIGHT) || (SCROLL_FWD(button)));
1644 button_left=((move_button & LEFT) || (SCROLL_BACK(button)));
1645
1646 if ((button_right && flip_sides==false) ||
1647 (button_left && flip_sides==true)) {
1648 if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) {
1649 for(k=0;k<used_balls;k++)
1650 if (start_game==1 || ball[k].glue)
1651 ball[k].pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH;
1652 pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH;
1653 }
1654 else {
1655 for(k=0;k<used_balls;k++)
1656 if ((start_game==1 || ball[k].glue))
1657 ball[k].pos_x+=8;
1658 pad_pos_x+=8;
1659 }
1660 }
1661 else if ((button_left && flip_sides==false) ||
1662 (button_right && flip_sides==true)) {
1663 if (pad_pos_x-8 < 0) {
1664 for(k=0;k<used_balls;k++)
1665 if (start_game==1 || ball[k].glue)
1666 ball[k].pos_x-=pad_pos_x;
1667 pad_pos_x-=pad_pos_x;
1668 }
1669 else {
1670 for(k=0;k<used_balls;k++)
1671 if (start_game==1 || ball[k].glue)
1672 ball[k].pos_x-=8;
1673 pad_pos_x-=8;
1674 }
1675 }
1676
1677
1678 switch(button) {
1679 case UP:
1680 case SELECT:
1681 if (start_game==1 && con_game!=1 && pad_type!=1) {
1682 for(k=0;k<used_balls;k++) {
1683 ball[k].y=-4;
1684 ball[k].x=pad_pos_x+(PAD_WIDTH/2)-2>=
1685 LCD_WIDTH/2?2:-2;
1686 }
1687 start_game =0;
1688 }
1689 else if (pad_type==1) {
1690 for(k=0;k<used_balls;k++) {
1691 if (ball[k].glue)
1692 ball[k].glue=false;
1693 else if (start_game==1) {
1694 ball[k].x = x[k];
1695 ball[k].y = y[k];
1696 }
1452 } 1697 }
1453 1698
1454 switch(game_menu(0)){ 1699 if (start_game!=1 && con_game==1) {
1455 case 0: 1700 start_game =0;
1456 life=2; 1701 con_game=0;
1457 cur_level=0; 1702 }
1458 int_game(1); 1703 } else if (pad_type==2 && con_game!=1) {
1459 break; 1704 int tfire;
1460 case 1: 1705 tfire=fire_space();
1461 con_game=1; 1706 fire[tfire].top=PAD_POS_Y-7;
1462 break; 1707 fire[tfire].left=pad_pos_x+1;
1463 case 2: 1708 tfire=fire_space();
1464 if (help(0)==1) return 1; 1709 fire[tfire].top=PAD_POS_Y-7;
1465 break; 1710 fire[tfire].left=pad_pos_x+PAD_WIDTH-1;
1466 case 3: 1711 } else if (con_game==1 && start_game!=1) {
1712 for(k=0;k<used_balls;k++) {
1713 ball[k].x=x[k];
1714 ball[k].y=y[k];
1715 }
1716 con_game=0;
1717 }
1718 break;
1719 case QUIT:
1720 switch(game_menu(1)) {
1721 case 0:
1722 life=2;
1723 cur_level=0;
1724 int_game(1);
1725 break;
1726 case 1:
1727 for(k=0;k<used_balls;k++)
1728 if (ball[k].x!=0 && ball[k].y !=0)
1729 con_game=1;
1730 break;
1731 case 2:
1732 if (help(1)==1)
1467 return 1; 1733 return 1;
1468 break; 1734 break;
1469 }; 1735 case 3:
1470 } 1736 return 1;
1471 } 1737 break;
1472 1738 }
1473 int move_button,button; 1739
1474 int button_right,button_left; 1740 for(k=0;k<used_balls;k++) {
1475 button=rb->button_get(false); 1741 if (ball[k].x!=0)
1476 move_button=rb->button_status(); 1742 x[k]=ball[k].x;
1477 1743 ball[k].x=0;
1478 button_right=((move_button & RIGHT) || (SCROLL_FWD(button))); 1744 if (ball[k].y!=0)
1479 button_left=((move_button & LEFT) || (SCROLL_BACK(button))); 1745 y[k]=ball[k].y;
1480 1746 ball[k].y=0;
1481 if ((button_right && flip_sides==false) || (button_left && flip_sides==true)) { 1747 }
1482 if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) { 1748
1483 for(k=0;k<used_balls;k++) 1749 break;
1484 if (start_game==1 || ball[k].glue) 1750
1485 ball[k].pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; 1751 default:
1486 pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; 1752 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
1487 } else { 1753 return 1;
1488 for(k=0;k<used_balls;k++) 1754 break;
1489 if ((start_game==1 || ball[k].glue)) 1755 }
1490 ball[k].pos_x+=8; 1756 }
1491 pad_pos_x+=8; 1757 else {
1492 }
1493 } else if ((button_left && flip_sides==false) || (button_right && flip_sides==true)) {
1494 if (pad_pos_x-8 < 0) {
1495 for(k=0;k<used_balls;k++)
1496 if (start_game==1 || ball[k].glue)
1497 ball[k].pos_x-=pad_pos_x;
1498 pad_pos_x-=pad_pos_x;
1499 } else {
1500 for(k=0;k<used_balls;k++)
1501 if (start_game==1 || ball[k].glue)
1502 ball[k].pos_x-=8;
1503 pad_pos_x-=8;
1504 }
1505 }
1506
1507
1508 switch(button) {
1509 case UP:
1510 case SELECT:
1511 if (start_game==1 && con_game!=1 && pad_type!=1) {
1512 for(k=0;k<used_balls;k++){
1513 ball[k].y=-4;
1514 ball[k].x=pad_pos_x+(PAD_WIDTH/2)-2>=LCD_WIDTH/2?2:-2;
1515 }
1516 start_game =0;
1517 } else if (pad_type==1) {
1518 for(k=0;k<used_balls;k++) {
1519 if (ball[k].glue)
1520 ball[k].glue=false;
1521 else if (start_game==1) {
1522 ball[k].x = x[k];
1523 ball[k].y = y[k];
1524 }
1525 }
1526
1527 if (start_game!=1 && con_game==1) {
1528 start_game =0;
1529 con_game=0;
1530 }
1531 } else if (pad_type==2 && con_game!=1) {
1532 int tfire;
1533 tfire=fire_space();
1534 fire[tfire].top=PAD_POS_Y-7;
1535 fire[tfire].left=pad_pos_x+1;
1536 tfire=fire_space();
1537 fire[tfire].top=PAD_POS_Y-7;
1538 fire[tfire].left=pad_pos_x+PAD_WIDTH-1;
1539 } else if (con_game==1 && start_game!=1) {
1540 for(k=0;k<used_balls;k++){
1541 ball[k].x=x[k];
1542 ball[k].y=y[k];
1543 }
1544 con_game=0;
1545 }
1546 break;
1547 case QUIT:
1548 switch(game_menu(1)){
1549 case 0:
1550 life=2;
1551 cur_level=0;
1552 int_game(1);
1553 break;
1554 case 1:
1555 for(k=0;k<used_balls;k++)
1556 if (ball[k].x!=0 && ball[k].y !=0)
1557 con_game=1;
1558 break;
1559 case 2:
1560 if (help(1)==1) return 1;
1561 break;
1562 case 3:
1563 return 1;
1564 break;
1565 };
1566
1567 for(k=0;k<used_balls;k++){
1568 if (ball[k].x!=0) x[k]=ball[k].x;
1569 ball[k].x=0;
1570 if (ball[k].y!=0) y[k]=ball[k].y;
1571 ball[k].y=0;
1572 }
1573
1574 break;
1575
1576 default:
1577 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
1578 return 1;
1579 break;
1580 }
1581 } else {
1582#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) 1758#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
1583 rb->splash(HZ*2,true,"Game Over"); 1759 rb->splash(HZ*2,true,"Game Over");
1584#else 1760#else
1585 rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); 1761 rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,
1586 rb->lcd_update(); 1762 110,52);
1763 rb->lcd_update();
1587#endif 1764#endif
1588 if (score>highscore) { 1765 if (score>highscore) {
1589 sleep(2); 1766 sleep(2);
1590 highscore=score; 1767 highscore=score;
1591 rb->splash(HZ*2,true,"New High Score"); 1768 rb->splash(HZ*2,true,"New High Score");
1592 } else { 1769 } else {
1593 sleep(3); 1770 sleep(3);
1594 }
1595
1596 for(k=0;k<used_balls;k++){
1597 ball[k].x=0;
1598 ball[k].y=0;
1599 }
1600
1601 switch(game_menu(0)){
1602 case 0:
1603 cur_level=0;
1604 life=2;
1605 int_game(1);
1606 break;
1607 case 1:
1608 con_game=1;
1609 break;
1610 case 2:
1611 if (help(0)==1) return 1;
1612 break;
1613 case 3:
1614 return 1;
1615 break;
1616 }
1617 } 1771 }
1618 if (end > *rb->current_tick) 1772
1773 for(k=0;k<used_balls;k++) {
1774 ball[k].x=0;
1775 ball[k].y=0;
1776 }
1777
1778 switch(game_menu(0)) {
1779 case 0:
1780 cur_level=0;
1781 life=2;
1782 int_game(1);
1783 break;
1784 case 1:
1785 con_game=1;
1786 break;
1787 case 2:
1788 if (help(0)==1)
1789 return 1;
1790 break;
1791 case 3:
1792 return 1;
1793 break;
1794 }
1795 }
1796 if (end > *rb->current_tick)
1619 rb->sleep(end-*rb->current_tick); 1797 rb->sleep(end-*rb->current_tick);
1620 else rb->yield(); 1798 else
1799 rb->yield();
1621 } 1800 }
1622} 1801}
1623 1802
@@ -1626,7 +1805,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1626{ 1805{
1627 (void)parameter; 1806 (void)parameter;
1628 rb = api; 1807 rb = api;
1629 1808
1630 rb->lcd_setfont(FONT_SYSFIXED); 1809 rb->lcd_setfont(FONT_SYSFIXED);
1631 /* Permanently enable the backlight (unless the user has turned it off) */ 1810 /* Permanently enable the backlight (unless the user has turned it off) */
1632 if (rb->global_settings->backlight_timeout > 0) 1811 if (rb->global_settings->backlight_timeout > 0)