diff options
author | Ben Basha <benbasha@rockbox.org> | 2006-02-19 21:24:46 +0000 |
---|---|---|
committer | Ben Basha <benbasha@rockbox.org> | 2006-02-19 21:24:46 +0000 |
commit | a39aeb1ed27aed71e223c685968035a610f1bcbd (patch) | |
tree | 0646e0edfa54ec9f31da7b17e2c3071ea8ffdcf9 /apps/plugins/brickmania.c | |
parent | 4b98554083155884dde7a49ae1d4e91ee038329e (diff) | |
download | rockbox-a39aeb1ed27aed71e223c685968035a610f1bcbd.tar.gz rockbox-a39aeb1ed27aed71e223c685968035a610f1bcbd.zip |
Patch #1418787 brickmania for the H1xx series by Dominik Wenger with changes by Liberman Shachar and me. +fixed bug with the glue pad.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8742 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/brickmania.c')
-rw-r--r-- | apps/plugins/brickmania.c | 258 |
1 files changed, 205 insertions, 53 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 937c4e473c..ac6204ca8c 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -18,15 +18,11 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | #include "gray.h" | ||
21 | #include "configfile.h" /* Part of libplugin */ | 22 | #include "configfile.h" /* Part of libplugin */ |
22 | 23 | ||
23 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
24 | 25 | ||
25 | /* The time (in ms) for one iteration through the game loop - decrease this | ||
26 | to speed up the game - note that current_tick is (currently) only accurate | ||
27 | to 10ms. | ||
28 | */ | ||
29 | #define CYCLETIME 30 | ||
30 | 26 | ||
31 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 27 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
32 | 28 | ||
@@ -83,9 +79,17 @@ extern const fb_data brickmania_powerups[]; | |||
83 | /* purple, red, blue, pink, green, yellow orange */ | 79 | /* purple, red, blue, pink, green, yellow orange */ |
84 | extern const fb_data brickmania_bricks[]; | 80 | extern const fb_data brickmania_bricks[]; |
85 | 81 | ||
82 | |||
83 | |||
86 | /* TO DO: This needs adjusting correctly for larger than 220x176 LCDS */ | 84 | /* TO DO: This needs adjusting correctly for larger than 220x176 LCDS */ |
87 | #if (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) | 85 | #if (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) |
88 | 86 | ||
87 | /* The time (in ms) for one iteration through the game loop - decrease this | ||
88 | to speed up the game - note that current_tick is (currently) only accurate | ||
89 | to 10ms. | ||
90 | */ | ||
91 | #define CYCLETIME 30 | ||
92 | |||
89 | /* Offsets for LCDS > 220x176 */ | 93 | /* Offsets for LCDS > 220x176 */ |
90 | #define XOFS ((LCD_WIDTH-220)/2) | 94 | #define XOFS ((LCD_WIDTH-220)/2) |
91 | #define YOFS ((LCD_HEIGHT-176)/2) | 95 | #define YOFS ((LCD_HEIGHT-176)/2) |
@@ -97,6 +101,7 @@ extern const fb_data brickmania_bricks[]; | |||
97 | #define BRICK_WIDTH 21 | 101 | #define BRICK_WIDTH 21 |
98 | #define BALL 5 | 102 | #define BALL 5 |
99 | #define LEFTMARGIN 5 | 103 | #define LEFTMARGIN 5 |
104 | #define TOPMARGIN 30 | ||
100 | 105 | ||
101 | #define BMPHEIGHT_help 19 | 106 | #define BMPHEIGHT_help 19 |
102 | #define BMPWIDTH_help 37 | 107 | #define BMPWIDTH_help 37 |
@@ -128,17 +133,89 @@ extern const fb_data brickmania_bricks[]; | |||
128 | #define BMPHEIGHT_powerup 6 | 133 | #define BMPHEIGHT_powerup 6 |
129 | #define BMPWIDTH_powerup 10 | 134 | #define BMPWIDTH_powerup 10 |
130 | 135 | ||
131 | #define BMPXOFS_resume (62+XOFS) | 136 | #define BMPHEIGHT_menu LCD_HEIGHT |
132 | #define BMPYOFS_resume (100+YOFS) | 137 | #define BMPWIDTH_menu LCD_WIDTH |
133 | #define BMPXOFS_quit (93+XOFS) | 138 | |
134 | #define BMPYOFS_quit (138+YOFS) | ||
135 | #define BMPXOFS_start (55+XOFS) | 139 | #define BMPXOFS_start (55+XOFS) |
136 | #define BMPYOFS_start (78+YOFS) | 140 | #define BMPYOFS_start (78+YOFS) |
141 | #define BMPXOFS_resume (62+XOFS) | ||
142 | #define BMPYOFS_resume (100+YOFS) | ||
137 | #define BMPXOFS_help (92+XOFS) | 143 | #define BMPXOFS_help (92+XOFS) |
138 | #define BMPYOFS_help (118+YOFS) | 144 | #define BMPYOFS_help (118+YOFS) |
145 | #define BMPXOFS_quit (93+XOFS) | ||
146 | #define BMPYOFS_quit (138+YOFS) | ||
139 | #define HIGHSCORE_XPOS (7+XOFS) | 147 | #define HIGHSCORE_XPOS (7+XOFS) |
140 | #define HIGHSCORE_YPOS (56+YOFS) | 148 | #define HIGHSCORE_YPOS (56+YOFS) |
141 | 149 | ||
150 | #define STRINGPOS_finsh 140 | ||
151 | #define STRINGPOS_congrats 157 | ||
152 | #define STRINGPOS_navi 150 | ||
153 | #define STRINGPOS_flipsides 150 | ||
154 | |||
155 | #elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH==2) | ||
156 | /* The time (in ms) for one iteration through the game loop - decrease this | ||
157 | to speed up the game - note that current_tick is (currently) only accurate | ||
158 | to 10ms. | ||
159 | */ | ||
160 | #define CYCLETIME 50 | ||
161 | |||
162 | #define PAD_WIDTH 30 | ||
163 | #define PAD_HEIGHT 5 | ||
164 | #define PAD_POS_Y LCD_HEIGHT - 7 | ||
165 | #define BRICK_HEIGHT 7 | ||
166 | #define BRICK_WIDTH 15 | ||
167 | #define BALL 5 | ||
168 | #define LEFTMARGIN 5 | ||
169 | #define TOPMARGIN 21 | ||
170 | |||
171 | #define BMPHEIGHT_help 15 | ||
172 | #define BMPWIDTH_help 30 | ||
173 | |||
174 | #define BMPHEIGHT_sel_help 15 | ||
175 | #define BMPWIDTH_sel_help 30 | ||
176 | |||
177 | #define BMPHEIGHT_resume 14 | ||
178 | #define BMPWIDTH_resume 78 | ||
179 | |||
180 | #define BMPHEIGHT_no_resume 14 | ||
181 | #define BMPWIDTH_no_resume 78 | ||
182 | |||
183 | #define BMPHEIGHT_quit 17 | ||
184 | #define BMPWIDTH_quit 30 | ||
185 | |||
186 | #define BMPHEIGHT_sel_quit 17 | ||
187 | #define BMPWIDTH_sel_quit 30 | ||
188 | |||
189 | #define BMPHEIGHT_sel_resume 14 | ||
190 | #define BMPWIDTH_sel_resume 78 | ||
191 | |||
192 | #define BMPHEIGHT_sel_start 16 | ||
193 | #define BMPWIDTH_sel_start 88 | ||
194 | |||
195 | #define BMPHEIGHT_start 16 | ||
196 | #define BMPWIDTH_start 88 | ||
197 | |||
198 | #define BMPHEIGHT_powerup 6 | ||
199 | #define BMPWIDTH_powerup 10 | ||
200 | |||
201 | #define BMPHEIGHT_menu 45 | ||
202 | #define BMPWIDTH_menu 160 | ||
203 | |||
204 | #define BMPXOFS_start 34 | ||
205 | #define BMPYOFS_start 64 | ||
206 | #define BMPXOFS_resume 38 | ||
207 | #define BMPYOFS_resume 77 | ||
208 | #define BMPXOFS_help 64 | ||
209 | #define BMPYOFS_help 90 | ||
210 | #define BMPXOFS_quit 64 | ||
211 | #define BMPYOFS_quit 103 | ||
212 | #define HIGHSCORE_XPOS 7 | ||
213 | #define HIGHSCORE_YPOS 36 | ||
214 | |||
215 | #define STRINGPOS_finsh 100 | ||
216 | #define STRINGPOS_congrats 110 | ||
217 | #define STRINGPOS_navi 100 | ||
218 | #define STRINGPOS_flipsides 100 | ||
142 | 219 | ||
143 | #else | 220 | #else |
144 | #error Unsupported LCD Size | 221 | #error Unsupported LCD Size |
@@ -524,7 +601,7 @@ void int_game(int new_game) | |||
524 | brick[i*10+j].hits=levels[cur_level][i][j]>=10? | 601 | brick[i*10+j].hits=levels[cur_level][i][j]>=10? |
525 | levels[cur_level][i][j]/16-1:0; | 602 | levels[cur_level][i][j]/16-1:0; |
526 | brick[i*10+j].hiteffect=0; | 603 | brick[i*10+j].hiteffect=0; |
527 | brick[i*10+j].powertop=30+i*10+BRICK_HEIGHT; | 604 | brick[i*10+j].powertop=TOPMARGIN+i*BRICK_HEIGHT+BRICK_HEIGHT; |
528 | brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1); | 605 | brick[i*10+j].used=(levels[cur_level][i][j]==0?0:1); |
529 | brick[i*10+j].color=(levels[cur_level][i][j]>=10? | 606 | brick[i*10+j].color=(levels[cur_level][i][j]>=10? |
530 | levels[cur_level][i][j]%16:levels[cur_level][i][j])-1; | 607 | levels[cur_level][i][j]%16:levels[cur_level][i][j])-1; |
@@ -569,8 +646,8 @@ int game_menu(int when) | |||
569 | { | 646 | { |
570 | int button,cur=0; | 647 | int button,cur=0; |
571 | char str[10]; | 648 | char str[10]; |
572 | 649 | rb->lcd_clear_display(); | |
573 | rb->lcd_bitmap(brickmania_menu_bg,0,0,LCD_WIDTH,LCD_HEIGHT); | 650 | rb->lcd_bitmap(brickmania_menu_bg,0,0,BMPWIDTH_menu,BMPHEIGHT_menu); |
574 | while (true) { | 651 | while (true) { |
575 | for(i=0;i<MENU_LENGTH;i++) { | 652 | for(i=0;i<MENU_LENGTH;i++) { |
576 | if (cur==0) | 653 | if (cur==0) |
@@ -615,8 +692,10 @@ int game_menu(int when) | |||
615 | 692 | ||
616 | /* high score */ | 693 | /* high score */ |
617 | rb->lcd_setfont(FONT_SYSFIXED); | 694 | rb->lcd_setfont(FONT_SYSFIXED); |
695 | #ifdef HAVE_LCD_COLOR | ||
618 | rb->lcd_set_background(LCD_RGBPACK(0,0,140)); | 696 | rb->lcd_set_background(LCD_RGBPACK(0,0,140)); |
619 | rb->lcd_set_foreground(LCD_WHITE); | 697 | rb->lcd_set_foreground(LCD_WHITE); |
698 | #endif | ||
620 | rb->lcd_putsxy(HIGHSCORE_XPOS, HIGHSCORE_YPOS, "High Score"); | 699 | rb->lcd_putsxy(HIGHSCORE_XPOS, HIGHSCORE_YPOS, "High Score"); |
621 | rb->snprintf(str, sizeof(str), "%d", highscore); | 700 | rb->snprintf(str, sizeof(str), "%d", highscore); |
622 | rb->lcd_getstringsize("High Score", &sw, NULL); | 701 | rb->lcd_getstringsize("High Score", &sw, NULL); |
@@ -664,6 +743,11 @@ int game_menu(int when) | |||
664 | case QUIT: | 743 | case QUIT: |
665 | return 3; | 744 | return 3; |
666 | break; | 745 | break; |
746 | |||
747 | default: | ||
748 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) | ||
749 | return 3; | ||
750 | break; | ||
667 | } | 751 | } |
668 | } | 752 | } |
669 | } | 753 | } |
@@ -672,38 +756,59 @@ int help(int when) | |||
672 | { | 756 | { |
673 | int w,h; | 757 | int w,h; |
674 | int button; | 758 | int button; |
759 | int xoffset=0; | ||
760 | int yoffset=0; | ||
761 | /* set the maximum x and y in the helpscreen | ||
762 | dont forget to update, if you change text */ | ||
763 | int maxY=160; | ||
764 | int maxX=210; | ||
675 | 765 | ||
676 | while(true){ | 766 | while(true){ |
677 | rb->lcd_setfont(FONT_SYSFIXED); | 767 | rb->lcd_setfont(FONT_SYSFIXED); |
768 | #ifdef HAVE_LCD_COLOR | ||
678 | rb->lcd_set_background(LCD_BLACK); | 769 | rb->lcd_set_background(LCD_BLACK); |
679 | rb->lcd_clear_display(); | 770 | rb->lcd_clear_display(); |
680 | rb->lcd_set_background(LCD_BLACK); | 771 | rb->lcd_set_background(LCD_BLACK); |
681 | rb->lcd_set_foreground(LCD_WHITE); | 772 | rb->lcd_set_foreground(LCD_WHITE); |
773 | #else | ||
774 | rb->lcd_clear_display(); | ||
775 | #endif | ||
682 | 776 | ||
683 | rb->lcd_getstringsize("BrickMania", &w, &h); | 777 | rb->lcd_getstringsize("BrickMania", &w, &h); |
684 | rb->lcd_putsxy(LCD_WIDTH/2-w/2, 1, "BrickMania"); | 778 | rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); |
685 | 779 | ||
780 | #ifdef HAVE_LCD_COLOR | ||
686 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | 781 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
687 | rb->lcd_putsxy(1, 1*(h+2),"Aim"); | 782 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); |
688 | rb->lcd_set_foreground(LCD_WHITE); | 783 | rb->lcd_set_foreground(LCD_WHITE); |
689 | rb->lcd_putsxy(1, 2*(h+2),"destroy all the bricks by bouncing"); | 784 | #else |
690 | rb->lcd_putsxy(1, 3*(h+2),"the ball of them using the paddle."); | 785 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); |
691 | 786 | #endif | |
787 | rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset,"destroy all the bricks by bouncing"); | ||
788 | rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset,"the ball of them using the paddle."); | ||
789 | #ifdef HAVE_LCD_COLOR | ||
692 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | 790 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
693 | rb->lcd_putsxy(1, 5*(h+2),"Controls"); | 791 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); |
694 | rb->lcd_set_foreground(LCD_WHITE); | 792 | rb->lcd_set_foreground(LCD_WHITE); |
695 | rb->lcd_putsxy(1, 6*(h+2),"< & > Move the paddle"); | 793 | #else |
696 | rb->lcd_putsxy(1, 7*(h+2),"NAVI Releases the ball/Fire!"); | 794 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); |
697 | rb->lcd_putsxy(1, 8*(h+2),"STOP Opens menu/Quit"); | 795 | #endif |
698 | 796 | rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); | |
797 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset,"NAVI Releases the ball/Fire!"); | ||
798 | rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset,"STOP Opens menu/Quit"); | ||
799 | #ifdef HAVE_LCD_COLOR | ||
699 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | 800 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); |
700 | rb->lcd_putsxy(1, 10*(h+2),"Specials"); | 801 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset,"Specials"); |
701 | rb->lcd_set_foreground(LCD_WHITE); | 802 | rb->lcd_set_foreground(LCD_WHITE); |
702 | rb->lcd_putsxy(1, 11*(h+2),"N Normal:returns paddle to normal"); | 803 | #else |
703 | rb->lcd_putsxy(1, 12*(h+2),"D DIE!:loses a life"); | 804 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset,"Specials"); |
704 | rb->lcd_putsxy(1, 13*(h+2),"L Life:gains a life/power up"); | 805 | #endif |
705 | rb->lcd_putsxy(1, 14*(h+2),"F Fire:allows you to shoot bricks"); | 806 | rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset,"N Normal:returns paddle to normal"); |
706 | rb->lcd_putsxy(1, 15*(h+2),"G Glue:ball sticks to paddle"); | 807 | rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset,"D DIE!:loses a life"); |
808 | rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset,"L Life:gains a life/power up"); | ||
809 | rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset,"F Fire:allows you to shoot bricks"); | ||
810 | rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset,"G Glue:ball sticks to paddle"); | ||
811 | rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset,"B Ball:Generates Another Ball"); | ||
707 | rb->lcd_update(); | 812 | rb->lcd_update(); |
708 | 813 | ||
709 | button=rb->button_get(true); | 814 | button=rb->button_get(true); |
@@ -728,6 +833,31 @@ int help(int when) | |||
728 | } | 833 | } |
729 | return NULL; | 834 | return NULL; |
730 | break; | 835 | break; |
836 | case LEFT: | ||
837 | case LEFT | BUTTON_REPEAT: | ||
838 | if( xoffset<0) | ||
839 | xoffset+=2; | ||
840 | break; | ||
841 | case RIGHT: | ||
842 | case RIGHT | BUTTON_REPEAT: | ||
843 | if(xoffset+maxX > LCD_WIDTH) | ||
844 | xoffset-=2; | ||
845 | break; | ||
846 | case UP: | ||
847 | case UP | BUTTON_REPEAT: | ||
848 | if(yoffset <0) | ||
849 | yoffset+=2; | ||
850 | break; | ||
851 | case DOWN: | ||
852 | case DOWN | BUTTON_REPEAT: | ||
853 | if(yoffset+maxY > LCD_HEIGHT) | ||
854 | yoffset-=2; | ||
855 | break; | ||
856 | |||
857 | default: | ||
858 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) | ||
859 | return 1; | ||
860 | break; | ||
731 | } | 861 | } |
732 | } | 862 | } |
733 | return NULL; | 863 | return NULL; |
@@ -793,11 +923,15 @@ int game_loop(void){ | |||
793 | end = *rb->current_tick + (CYCLETIME * HZ) / 1000; | 923 | end = *rb->current_tick + (CYCLETIME * HZ) / 1000; |
794 | 924 | ||
795 | if (life >= 0) { | 925 | if (life >= 0) { |
926 | #ifdef HAVE_LCD_COLOR | ||
796 | rb->lcd_set_background(LCD_BLACK); | 927 | rb->lcd_set_background(LCD_BLACK); |
797 | rb->lcd_set_drawmode(DRMODE_SOLID); | 928 | rb->lcd_set_drawmode(DRMODE_SOLID); |
798 | rb->lcd_clear_display(); | 929 | rb->lcd_clear_display(); |
799 | rb->lcd_set_background(LCD_BLACK); | 930 | rb->lcd_set_background(LCD_BLACK); |
800 | rb->lcd_set_foreground(LCD_WHITE); | 931 | rb->lcd_set_foreground(LCD_WHITE); |
932 | #else | ||
933 | rb->lcd_clear_display(); | ||
934 | #endif | ||
801 | 935 | ||
802 | if (flip_sides) { | 936 | if (flip_sides) { |
803 | if (*rb->current_tick>=sec_count){ | 937 | if (*rb->current_tick>=sec_count){ |
@@ -809,7 +943,7 @@ int game_loop(void){ | |||
809 | } | 943 | } |
810 | rb->snprintf(s, sizeof(s), "%d", num_count); | 944 | rb->snprintf(s, sizeof(s), "%d", num_count); |
811 | rb->lcd_getstringsize(s, &sw, NULL); | 945 | rb->lcd_getstringsize(s, &sw, NULL); |
812 | rb->lcd_putsxy(LCD_WIDTH/2-2, 150, s); | 946 | rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_flipsides, s); |
813 | } | 947 | } |
814 | 948 | ||
815 | /* write life num */ | 949 | /* write life num */ |
@@ -828,7 +962,7 @@ int game_loop(void){ | |||
828 | /* continue game */ | 962 | /* continue game */ |
829 | if (con_game== 1 && start_game!=1) { | 963 | if (con_game== 1 && start_game!=1) { |
830 | rb->lcd_getstringsize("Press NAVI To Continue", &sw, NULL); | 964 | rb->lcd_getstringsize("Press NAVI To Continue", &sw, NULL); |
831 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 150, "Press NAVI to continue"); | 965 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_navi, "Press NAVI to continue"); |
832 | sec_count=*rb->current_tick+HZ; | 966 | sec_count=*rb->current_tick+HZ; |
833 | } | 967 | } |
834 | 968 | ||
@@ -911,7 +1045,7 @@ int game_loop(void){ | |||
911 | brick[i*10+j].poweruse=1; | 1045 | brick[i*10+j].poweruse=1; |
912 | 1046 | ||
913 | brickx=LEFTMARGIN+j*BRICK_WIDTH; | 1047 | brickx=LEFTMARGIN+j*BRICK_WIDTH; |
914 | bricky=30+i*8; | 1048 | bricky=TOPMARGIN+i*BRICK_HEIGHT; |
915 | if (pad_type==2) { | 1049 | if (pad_type==2) { |
916 | for (k=0;k<=30;k++) { | 1050 | for (k=0;k<=30;k++) { |
917 | if (fire[k].top+7>0) { | 1051 | if (fire[k].top+7>0) { |
@@ -934,9 +1068,11 @@ int game_loop(void){ | |||
934 | } | 1068 | } |
935 | 1069 | ||
936 | if (brick[i*10+j].used==1){ | 1070 | if (brick[i*10+j].used==1){ |
937 | 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); | 1071 | 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); |
1072 | #ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ | ||
938 | if (brick[i*10+j].hiteffect>0) | 1073 | if (brick[i*10+j].hiteffect>0) |
939 | 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); | 1074 | 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); |
1075 | #endif | ||
940 | } | 1076 | } |
941 | 1077 | ||
942 | for(k=0;k<used_balls;k++) { | 1078 | for(k=0;k<used_balls;k++) { |
@@ -1073,30 +1209,41 @@ int game_loop(void){ | |||
1073 | ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; | 1209 | ball[k].pos_x = ball[k].pos_x <= 0 ? 0 : LCD_WIDTH-BALL; |
1074 | } | 1210 | } |
1075 | 1211 | ||
1076 | 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)) && | 1212 | 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)) && |
1077 | start_game != 1 && !ball[k].glue) { | 1213 | start_game != 1 && !ball[k].glue) { |
1078 | 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)) { | 1214 | |
1079 | ball[k].y = 2*-1; | 1215 | if ((ball[k].pos_x+3 >= pad_pos_x && ball[k].pos_x+3 <= pad_pos_x+(PAD_WIDTH/2/4)) || |
1080 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) | 1216 | (ball[k].pos_x +3>= pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) && ball[k].pos_x+3 <= pad_pos_x+PAD_WIDTH)) { |
1081 | ball[k].x = pad_check(6,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); | 1217 | |
1082 | } 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)) { | 1218 | ball[k].y = -2; |
1083 | ball[k].y = 3*-1; | 1219 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) |
1084 | 1220 | ball[k].x = pad_check(6,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); | |
1221 | |||
1222 | } else if ((ball[k].pos_x+3 >= pad_pos_x+(PAD_WIDTH/2/4) && ball[k].pos_x+3 <= pad_pos_x+2*(PAD_WIDTH/2/4)) || | ||
1223 | (ball[k].pos_x+3 >= pad_pos_x+(PAD_WIDTH-2*(PAD_WIDTH/2/4)) && ball[k].pos_x+3 <= pad_pos_x+(PAD_WIDTH-(PAD_WIDTH/2/4)) )) { | ||
1224 | |||
1225 | ball[k].y = -3; | ||
1085 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) | 1226 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) |
1086 | ball[k].x = pad_check(4,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); | 1227 | ball[k].x = pad_check(4,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); |
1087 | } 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)) { | 1228 | |
1088 | ball[k].y = 4*-1; | 1229 | } else if ((ball[k].pos_x+3 >= pad_pos_x+2*(PAD_WIDTH/2/4) && ball[k].pos_x+3 <= pad_pos_x+3*(PAD_WIDTH/2/4)) || |
1089 | 1230 | (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)) )) { | |
1231 | |||
1232 | ball[k].y = -4; | ||
1090 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) | 1233 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) |
1091 | ball[k].x = pad_check(3,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); | 1234 | ball[k].x = pad_check(3,0,ball[k].pos_x+2<=pad_pos_x+(PAD_WIDTH/2)?0:1,k); |
1092 | } 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)) { | 1235 | |
1093 | ball[k].y = 4*-1; | 1236 | } else if ((ball[k].pos_x+3 >= pad_pos_x+3*(PAD_WIDTH/2/4) && ball[k].pos_x+3 <= pad_pos_x+4*(PAD_WIDTH/2/4)-2) || |
1237 | (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)) )) { | ||
1238 | |||
1239 | ball[k].y = -4; | ||
1094 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) | 1240 | if (ball[k].pos_x != 0 && ball[k].pos_x+BALL!=LCD_WIDTH) |
1095 | ball[k].x = pad_check(2,1,NULL,k); | 1241 | ball[k].x = pad_check(2,1,NULL,k); |
1096 | } else { | 1242 | |
1097 | ball[k].y = 4*-1; | 1243 | } else { |
1098 | } | 1244 | ball[k].y = -4; |
1099 | } | 1245 | } |
1246 | } | ||
1100 | 1247 | ||
1101 | if (!ball[k].glue) { | 1248 | if (!ball[k].glue) { |
1102 | ball[k].pos_x+=ball[k].tempx!=0?ball[k].tempx:ball[k].x; | 1249 | ball[k].pos_x+=ball[k].tempx!=0?ball[k].tempx:ball[k].x; |
@@ -1112,7 +1259,7 @@ int game_loop(void){ | |||
1112 | ball[k].pos_y=PAD_POS_Y-BALL; | 1259 | ball[k].pos_y=PAD_POS_Y-BALL; |
1113 | ball[k].glue=true; | 1260 | ball[k].glue=true; |
1114 | } | 1261 | } |
1115 | } /* for k */ | 1262 | } /* for k */ |
1116 | 1263 | ||
1117 | rb->lcd_update(); | 1264 | rb->lcd_update(); |
1118 | 1265 | ||
@@ -1124,9 +1271,9 @@ int game_loop(void){ | |||
1124 | sleep(2); | 1271 | sleep(2); |
1125 | } else { | 1272 | } else { |
1126 | rb->lcd_getstringsize("Congratulations!", &sw, NULL); | 1273 | rb->lcd_getstringsize("Congratulations!", &sw, NULL); |
1127 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 140, "Congratulations!"); | 1274 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_congrats, "Congratulations!"); |
1128 | rb->lcd_getstringsize("You have finished the game!", &sw, NULL); | 1275 | rb->lcd_getstringsize("You have finished the game!", &sw, NULL); |
1129 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 157, "You have finished the game!"); | 1276 | rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_finsh, "You have finished the game!"); |
1130 | vscore=score; | 1277 | vscore=score; |
1131 | rb->lcd_update(); | 1278 | rb->lcd_update(); |
1132 | if (score>highscore) { | 1279 | if (score>highscore) { |
@@ -1203,7 +1350,7 @@ int game_loop(void){ | |||
1203 | for(k=0;k<used_balls;k++) { | 1350 | for(k=0;k<used_balls;k++) { |
1204 | if (ball[k].glue) | 1351 | if (ball[k].glue) |
1205 | ball[k].glue=false; | 1352 | ball[k].glue=false; |
1206 | else { | 1353 | else if (start_game==1) { |
1207 | ball[k].x = x[k]; | 1354 | ball[k].x = x[k]; |
1208 | ball[k].y = y[k]; | 1355 | ball[k].y = y[k]; |
1209 | } | 1356 | } |
@@ -1257,6 +1404,11 @@ int game_loop(void){ | |||
1257 | } | 1404 | } |
1258 | 1405 | ||
1259 | break; | 1406 | break; |
1407 | |||
1408 | default: | ||
1409 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) | ||
1410 | return 1; | ||
1411 | break; | ||
1260 | } | 1412 | } |
1261 | } else { | 1413 | } else { |
1262 | rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); | 1414 | rb->lcd_bitmap(brickmania_gameover,LCD_WIDTH/2-55,LCD_HEIGHT-87,110,52); |