1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Originally by Joshua Oreman, improved by Prashant Varanasi
11 * Ported to Rockbox by Ben Basha (Paprica)
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
25 #include "lib/configfile.h"
26 #include "lib/helper.h"
27 #include "lib/playback_control.h"
33 - Make original speed and further increases in speed depend more on screen size
34 - attempt to make the tunnels get narrower as the game goes on
35 - make the chopper look better, maybe a picture, and scale according
37 - use textures for the color screens for background and terrain,
38 eg stars on background
39 - allow choice of different levels [later: different screen themes]
40 - better high score handling, improved screen etc.
43 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
45 #define QUIT BUTTON_OFF
46 #define ACTION BUTTON_UP
47 #define ACTION2 BUTTON_SELECT
48 #define ACTIONTEXT "SELECT"
50 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
51 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
52 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
54 #define QUIT BUTTON_MENU
55 #define ACTION BUTTON_SELECT
56 #define ACTIONTEXT "SELECT"
58 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD /* grayscale at the moment */
60 #define QUIT BUTTON_POWER
61 #define ACTION BUTTON_UP
62 #define ACTION2 BUTTON_SELECT
63 #define ACTIONTEXT "SELECT"
65 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
66 #define QUIT BUTTON_POWER
67 #define ACTION BUTTON_RIGHT
68 #define ACTIONTEXT "RIGHT"
70 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
71 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
72 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
73 (CONFIG_KEYPAD == SANSA_M200_PAD) || \
74 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
75 #define QUIT BUTTON_POWER
76 #define ACTION BUTTON_SELECT
77 #define ACTIONTEXT "SELECT"
79 #elif CONFIG_KEYPAD == GIGABEAT_PAD
80 #define QUIT BUTTON_MENU
81 #define ACTION BUTTON_SELECT
82 #define ACTIONTEXT "SELECT"
84 #elif CONFIG_KEYPAD == RECORDER_PAD
85 #define QUIT BUTTON_OFF
86 #define ACTION BUTTON_PLAY
87 #define ACTIONTEXT "PLAY"
89 #elif CONFIG_KEYPAD == ONDIO_PAD
90 #define QUIT BUTTON_OFF
91 #define ACTION BUTTON_UP
92 #define ACTION2 BUTTON_MENU
93 #define ACTIONTEXT "UP"
95 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
96 #define QUIT BUTTON_BACK
97 #define ACTION BUTTON_SELECT
98 #define ACTION2 BUTTON_MENU
99 #define ACTIONTEXT "SELECT"
101 #elif CONFIG_KEYPAD == MROBE100_PAD
102 #define QUIT BUTTON_POWER
103 #define ACTION BUTTON_SELECT
104 #define ACTIONTEXT "SELECT"
106 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
107 #define QUIT BUTTON_RC_REC
108 #define ACTION BUTTON_RC_PLAY
109 #define ACTION2 BUTTON_RC_MODE
110 #define ACTIONTEXT "PLAY"
112 #elif CONFIG_KEYPAD == COWOND2_PAD
113 #define QUIT BUTTON_POWER
115 #elif CONFIG_KEYPAD == IAUDIO67_PAD
116 #define QUIT BUTTON_POWER
117 #define ACTION BUTTON_PLAY
118 #define ACTION2 BUTTON_STOP
119 #define ACTIONTEXT "PLAY"
121 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
122 #define QUIT BUTTON_BACK
123 #define ACTION BUTTON_UP
124 #define ACTION2 BUTTON_MENU
125 #define ACTIONTEXT "UP"
127 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
128 #define QUIT BUTTON_POWER
129 #define ACTION BUTTON_MENU
130 #define ACTION2 BUTTON_SELECT
131 #define ACTIONTEXT "MENU"
134 #error No keymap defined!
137 #ifdef HAVE_TOUCHSCREEN
139 #define QUIT BUTTON_TOPLEFT
142 #define ACTION BUTTON_BOTTOMLEFT
145 #define ACTION2 BUTTON_BOTTOMRIGHT
148 #define ACTIONTEXT "BOTTOMRIGHT"
152 #define NUMBER_OF_BLOCKS 8
153 #define NUMBER_OF_PARTICLES 3
154 #define MAX_TERRAIN_NODES 15
156 #define LEVEL_MODE_NORMAL 0
157 #define LEVEL_MODE_STEEP 1
160 #define CYCLETIME 100
161 #define SCALE(x) ((x)==1 ? (x) : ((x) >> 1))
169 /*Chopper's local variables to track the terrain position etc*/
170 static int chopCounter
;
171 static int iRotorOffset
;
174 static int iPlayerPosX
;
175 static int iPlayerPosY
;
176 static int iCameraPosX
;
177 static int iPlayerSpeedX
;
178 static int iPlayerSpeedY
;
179 static int iLastBlockPlacedPosX
;
180 static int iGravityTimerCountdown
;
181 static int iPlayerAlive
;
182 static int iLevelMode
;
183 static int blockh
,blockw
;
184 static int highscore
;
187 #define CFG_FILE "chopper.cfg"
188 #define MAX_POINTS 50000
189 static struct configdata config
[] =
191 {TYPE_INT
, 0, MAX_POINTS
, { .int_p
= &highscore
}, "highscore", NULL
}
224 struct CTerrainNode mNodes
[MAX_TERRAIN_NODES
];
226 int iLastNodePlacedPosX
;
229 struct CBlock mBlocks
[NUMBER_OF_BLOCKS
];
230 struct CParticle mParticles
[NUMBER_OF_PARTICLES
];
232 struct CTerrain mGround
;
233 struct CTerrain mRoof
;
235 /*Function declarations*/
236 static void chopDrawParticle(struct CParticle
*mParticle
);
237 static void chopDrawBlock(struct CBlock
*mBlock
);
238 static void chopRenderTerrain(struct CTerrain
*ter
);
239 void chopper_load(bool newgame
);
240 void cleanup_chopper(void);
242 static void chopDrawPlayer(int x
,int y
) /* These are SCREEN coords, not world!*/
246 rb
->lcd_set_foreground(LCD_RGBPACK(50,50,200));
248 rb
->lcd_set_foreground(LCD_DARKGRAY
);
250 rb
->lcd_fillrect(SCALE(x
+6), SCALE(y
+2), SCALE(12), SCALE(9));
251 rb
->lcd_fillrect(SCALE(x
-3), SCALE(y
+6), SCALE(20), SCALE(3));
254 rb
->lcd_set_foreground(LCD_RGBPACK(50,50,50));
256 rb
->lcd_set_foreground(LCD_DARKGRAY
);
258 rb
->lcd_fillrect(SCALE(x
+10), SCALE(y
), SCALE(2), SCALE(3));
259 rb
->lcd_fillrect(SCALE(x
+10), SCALE(y
), SCALE(1), SCALE(3));
262 rb
->lcd_set_foreground(LCD_RGBPACK(40,40,100));
264 rb
->lcd_set_foreground(LCD_BLACK
);
266 rb
->lcd_drawline(SCALE(x
), SCALE(y
+iRotorOffset
), SCALE(x
+20),
267 SCALE(y
-iRotorOffset
));
270 rb
->lcd_set_foreground(LCD_RGBPACK(20,20,50));
272 rb
->lcd_set_foreground(LCD_BLACK
);
274 rb
->lcd_fillrect(SCALE(x
- 2), SCALE(y
+ 5), SCALE(2), SCALE(5));
278 static void chopClearTerrain(struct CTerrain
*ter
)
280 ter
->iNodesCount
= 0;
284 int iR(int low
,int high
)
286 return low
+rb
->rand()%(high
-low
+1);
289 static void chopCopyTerrain(struct CTerrain
*src
, struct CTerrain
*dest
,
290 int xOffset
,int yOffset
)
294 while(i
< src
->iNodesCount
)
296 dest
->mNodes
[i
].x
= src
->mNodes
[i
].x
+ xOffset
;
297 dest
->mNodes
[i
].y
= src
->mNodes
[i
].y
+ yOffset
;
302 dest
->iNodesCount
= src
->iNodesCount
;
303 dest
->iLastNodePlacedPosX
= src
->iLastNodePlacedPosX
;
307 static void chopAddTerrainNode(struct CTerrain
*ter
, int x
, int y
)
311 if(ter
->iNodesCount
+ 1 >= MAX_TERRAIN_NODES
)
313 /* DEBUGF("ERROR: Not enough nodes!\n"); */
319 i
= ter
->iNodesCount
- 1;
321 ter
->mNodes
[i
].x
= x
;
324 ter
->iLastNodePlacedPosX
= x
;
328 static void chopTerrainNodeDeleteAndShift(struct CTerrain
*ter
,int nodeIndex
)
332 while( i
< ter
->iNodesCount
)
334 ter
->mNodes
[i
- 1] = ter
->mNodes
[i
];
343 int chopUpdateTerrainRecycling(struct CTerrain
*ter
)
348 while(i
< ter
->iNodesCount
)
351 if( iCameraPosX
> ter
->mNodes
[i
].x
)
354 chopTerrainNodeDeleteAndShift(ter
,i
);
356 iNewNodePos
= ter
->iLastNodePlacedPosX
+ 50;
362 if(iLevelMode
== LEVEL_MODE_STEEP
)
365 chopAddTerrainNode(ter
,iNewNodePos
,g
- iR(-v
,v
));
377 int chopTerrainHeightAtPoint(struct CTerrain
*ter
, int pX
)
380 int iNodeIndexOne
=0,iNodeIndexTwo
=0, h
, terY1
, terY2
, terX1
, terX2
, a
, b
;
384 for(i
=1;i
<MAX_TERRAIN_NODES
;i
++)
386 if(ter
->mNodes
[i
].x
> pX
)
388 iNodeIndexOne
= i
- 1;
394 iNodeIndexTwo
= iNodeIndexOne
+ 1;
395 terY1
= ter
->mNodes
[iNodeIndexOne
].y
;
396 terY2
= ter
->mNodes
[iNodeIndexTwo
].y
;
399 terX2
= ter
->mNodes
[iNodeIndexTwo
].x
- ter
->mNodes
[iNodeIndexOne
].x
;
401 pX
-= ter
->mNodes
[iNodeIndexOne
].x
;
414 int chopPointInTerrain(struct CTerrain
*ter
, int pX
, int pY
, int iTestType
)
416 int h
= chopTerrainHeightAtPoint(ter
, pX
);
424 static void chopAddBlock(int x
,int y
,int sx
,int sy
, int indexOverride
)
428 if(indexOverride
< 0)
430 while(mBlocks
[i
].bIsActive
&& i
< NUMBER_OF_BLOCKS
)
432 if(i
==NUMBER_OF_BLOCKS
)
434 DEBUGF("No blocks!\n");
441 mBlocks
[i
].bIsActive
= 1;
442 mBlocks
[i
].iWorldX
= x
;
443 mBlocks
[i
].iWorldY
= y
;
444 mBlocks
[i
].iSizeX
= sx
;
445 mBlocks
[i
].iSizeY
= sy
;
447 iLastBlockPlacedPosX
= x
;
450 static void chopAddParticle(int x
,int y
,int sx
,int sy
)
454 while(mParticles
[i
].bIsActive
&& i
< NUMBER_OF_PARTICLES
)
457 if(i
==NUMBER_OF_PARTICLES
)
460 mParticles
[i
].bIsActive
= 1;
461 mParticles
[i
].iWorldX
= x
;
462 mParticles
[i
].iWorldY
= y
;
463 mParticles
[i
].iSpeedX
= sx
;
464 mParticles
[i
].iSpeedY
= sy
;
467 static void chopGenerateBlockIfNeeded(void)
470 int DistSpeedX
= iPlayerSpeedX
* 5;
471 if(DistSpeedX
<200) DistSpeedX
= 200;
473 while(i
< NUMBER_OF_BLOCKS
)
475 if(!mBlocks
[i
].bIsActive
)
479 iX
= iLastBlockPlacedPosX
+ (350-DistSpeedX
);
483 sY
= blockh
+ iR(1,blockh
/3);
485 chopAddBlock(iX
,iY
,sX
,sY
,i
);
493 static int chopBlockCollideWithPlayer(struct CBlock
*mBlock
)
495 int px
= iPlayerPosX
;
496 int py
= iPlayerPosY
;
498 int x
= mBlock
->iWorldX
-17;
499 int y
= mBlock
->iWorldY
-11;
501 int x2
= x
+ mBlock
->iSizeX
+17;
502 int y2
= y
+ mBlock
->iSizeY
+11;
515 static int chopBlockOffscreen(struct CBlock
*mBlock
)
517 if(mBlock
->iWorldX
+ mBlock
->iSizeX
< iCameraPosX
)
523 static int chopParticleOffscreen(struct CParticle
*mParticle
)
525 if (mParticle
->iWorldX
< iCameraPosX
|| mParticle
->iWorldY
< 0 ||
526 mParticle
->iWorldY
> iScreenY
|| mParticle
->iWorldX
> iCameraPosX
+
535 static void chopKillPlayer(void)
539 for (i
= 0; i
< NUMBER_OF_PARTICLES
; i
++) {
540 mParticles
[i
].bIsActive
= 0;
541 chopAddParticle(iPlayerPosX
+ iR(0,20), iPlayerPosY
+ iR(0,20),
547 if (iPlayerAlive
== 0) {
548 rb
->lcd_set_drawmode(DRMODE_FG
);
550 rb
->lcd_set_foreground(LCD_LIGHTGRAY
);
552 rb
->splash(HZ
, "Game Over");
554 if (score
> highscore
) {
557 rb
->snprintf(scoretext
, sizeof(scoretext
), "New High Score: %d",
559 rb
->splash(HZ
*2, scoretext
);
562 rb
->splash(HZ
/4, "Press " ACTIONTEXT
" to continue");
565 rb
->lcd_set_drawmode(DRMODE_SOLID
);
568 button
= rb
->button_get(true);
575 button
= rb
->button_get(true);
576 if (button
== (ACTION
| BUTTON_REL
)
578 || button
== (ACTION2
| BUTTON_REL
)
593 static void chopDrawTheWorld(void)
597 while(i
< NUMBER_OF_BLOCKS
)
599 if(mBlocks
[i
].bIsActive
)
601 if(chopBlockOffscreen(&mBlocks
[i
]) == 1)
602 mBlocks
[i
].bIsActive
= 0;
604 chopDrawBlock(&mBlocks
[i
]);
612 while(i
< NUMBER_OF_PARTICLES
)
614 if(mParticles
[i
].bIsActive
)
616 if(chopParticleOffscreen(&mParticles
[i
]) == 1)
617 mParticles
[i
].bIsActive
= 0;
619 chopDrawParticle(&mParticles
[i
]);
625 chopRenderTerrain(&mGround
);
626 chopRenderTerrain(&mRoof
);
630 static void chopDrawParticle(struct CParticle
*mParticle
)
633 int iPosX
= (mParticle
->iWorldX
- iCameraPosX
);
634 int iPosY
= (mParticle
->iWorldY
);
636 rb
->lcd_set_foreground(LCD_RGBPACK(192,192,192));
638 rb
->lcd_set_foreground(LCD_LIGHTGRAY
);
640 rb
->lcd_fillrect(SCALE(iPosX
), SCALE(iPosY
), SCALE(3), SCALE(3));
644 static void chopDrawScene(void)
649 rb
->lcd_set_background(LCD_BLACK
);
651 rb
->lcd_set_background(LCD_WHITE
);
653 rb
->lcd_clear_display();
656 chopDrawPlayer(iPlayerPosX
- iCameraPosX
, iPlayerPosY
);
658 score
= -20 + iPlayerPosX
/3;
661 rb
->lcd_set_drawmode(DRMODE_COMPLEMENT
);
663 rb
->lcd_set_drawmode(DRMODE_FG
);
667 rb
->lcd_set_foreground(LCD_BLACK
);
669 rb
->lcd_set_foreground(LCD_WHITE
);
673 rb
->snprintf(s
, sizeof(s
), "Dist: %d", score
);
675 rb
->snprintf(s
, sizeof(s
), "Distance: %d", score
);
677 rb
->lcd_getstringsize(s
, &w
, NULL
);
678 rb
->lcd_putsxy(2, 2, s
);
679 if (score
< highscore
)
683 rb
->snprintf(s
, sizeof(s
), "Hi: %d", highscore
);
685 rb
->snprintf(s
, sizeof(s
), "Best: %d", highscore
);
687 rb
->lcd_getstringsize(s
, &w2
, NULL
);
688 if (LCD_WIDTH
- 2 - w2
> w
+ 2)
689 rb
->lcd_putsxy(LCD_WIDTH
- 2 - w2
, 2, s
);
691 rb
->lcd_set_drawmode(DRMODE_SOLID
);
696 static int chopMenu(int menunum
)
698 int result
= (menunum
==0)?0:1;
700 bool menu_quit
= false;
702 static const struct opt_items levels
[2] = {
707 MENUITEM_STRINGLIST(menu
,"Chopper Menu",NULL
,"Start New Game","Resume Game",
708 "Level","Playback Control","Quit");
710 #ifdef HAVE_LCD_COLOR
711 rb
->lcd_set_foreground(LCD_WHITE
);
712 rb
->lcd_set_background(LCD_BLACK
);
714 rb
->lcd_set_foreground(LCD_BLACK
);
715 rb
->lcd_set_background(LCD_WHITE
);
718 rb
->lcd_clear_display();
721 switch(rb
->do_menu(&menu
, &result
, NULL
, false))
723 case 0: /* Start New Game */
728 case 1: /* Resume Game */
732 } else if(menunum
==0){
733 rb
->splash(HZ
, "No game to resume");
737 rb
->set_option("Level", &iLevelMode
, INT
, levels
, 2, NULL
);
740 playback_control(NULL
);
746 case MENU_ATTACHED_USB
:
748 res
= PLUGIN_USB_CONNECTED
;
752 rb
->lcd_clear_display();
756 static int chopGameLoop(void)
758 int move_button
, ret
;
760 int end
, i
=0, bdelay
=0, last_button
=BUTTON_NONE
;
762 if (chopUpdateTerrainRecycling(&mGround
) == 1)
763 /* mirror the sky if we've changed the ground */
764 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
774 end
= *rb
->current_tick
+ (CYCLETIME
* HZ
) / 1000;
776 if(chopUpdateTerrainRecycling(&mGround
) == 1)
777 /* mirror the sky if we've changed the ground */
778 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
780 iRotorOffset
= iR(-1,1);
782 /* We need to have this here so particles move when we're dead */
784 for (i
=0; i
< NUMBER_OF_PARTICLES
; i
++)
785 if(mParticles
[i
].bIsActive
== 1)
787 mParticles
[i
].iWorldX
+= mParticles
[i
].iSpeedX
;
788 mParticles
[i
].iWorldY
+= mParticles
[i
].iSpeedY
;
791 /* Redraw the main window: */
795 iGravityTimerCountdown
--;
797 if(iGravityTimerCountdown
<= 0)
799 iGravityTimerCountdown
= 3;
800 chopAddParticle(iPlayerPosX
, iPlayerPosY
+5, 0, 0);
803 if(iLevelMode
== LEVEL_MODE_NORMAL
)
804 chopGenerateBlockIfNeeded();
807 move_button
=rb
->button_status();
808 if (rb
->button_get(false) == QUIT
) {
813 last_button
= BUTTON_NONE
;
814 move_button
= BUTTON_NONE
;
817 switch (move_button
) {
822 if (last_button
!= ACTION
824 && last_button
!= ACTION2
833 if (last_button
== ACTION
835 || last_button
== ACTION2
842 if (rb
->default_event_handler(move_button
) == SYS_USB_CONNECTED
)
843 return PLUGIN_USB_CONNECTED
;
846 last_button
= move_button
;
849 iPlayerSpeedY
= bdelay
;
851 } else if (bdelay
> 0) {
852 iPlayerSpeedY
= bdelay
;
856 iCameraPosX
= iPlayerPosX
- 25;
857 iPlayerPosX
+= iPlayerSpeedX
;
858 iPlayerPosY
+= iPlayerSpeedY
;
861 /* increase speed as we go along */
862 if (chopCounter
== 100){
867 if (iPlayerPosY
> iScreenY
-10 || iPlayerPosY
< -5 ||
868 chopPointInTerrain(&mGround
, iPlayerPosX
, iPlayerPosY
+ 10, 0) ||
869 chopPointInTerrain(&mRoof
, iPlayerPosX
,iPlayerPosY
, 1))
878 for (i
=0; i
< NUMBER_OF_BLOCKS
; i
++)
879 if(mBlocks
[i
].bIsActive
== 1)
880 if(chopBlockCollideWithPlayer(&mBlocks
[i
])) {
888 if (end
> *rb
->current_tick
)
889 rb
->sleep(end
-*rb
->current_tick
);
897 static void chopDrawBlock(struct CBlock
*mBlock
)
899 int iPosX
= (mBlock
->iWorldX
- iCameraPosX
);
900 int iPosY
= (mBlock
->iWorldY
);
902 rb
->lcd_set_foreground(LCD_RGBPACK(100,255,100));
904 rb
->lcd_set_foreground(LCD_BLACK
);
906 rb
->lcd_fillrect(SCALE(iPosX
), SCALE(iPosY
), SCALE(mBlock
->iSizeX
),
907 SCALE(mBlock
->iSizeY
));
911 static void chopRenderTerrain(struct CTerrain
*ter
)
919 if(ter
->mNodes
[0].y
< (LCD_HEIGHT
*SIZE
)/2)
922 ay
=(LCD_HEIGHT
*SIZE
);
924 while(i
< ter
->iNodesCount
&& oldx
< iScreenX
)
927 int x
= ter
->mNodes
[i
-1].x
- iCameraPosX
;
928 int y
= ter
->mNodes
[i
-1].y
;
930 int x2
= ter
->mNodes
[i
].x
- iCameraPosX
;
931 int y2
= ter
->mNodes
[i
].y
;
933 rb
->lcd_set_foreground(LCD_RGBPACK(100,255,100));
935 rb
->lcd_set_foreground(LCD_DARKGRAY
);
938 rb
->lcd_drawline(SCALE(x
), SCALE(y
), SCALE(x2
), SCALE(y2
));
940 xlcd_filltriangle(SCALE(x
), SCALE(y
), SCALE(x2
), SCALE(y2
),
941 SCALE(x2
), SCALE(ay
));
942 xlcd_filltriangle(SCALE(x
), SCALE(ay
), SCALE(x2
), SCALE(y2
),
943 SCALE(x2
), SCALE(ay
));
946 xlcd_filltriangle(SCALE(x
), SCALE(ay
), SCALE(x
), SCALE(y
),
947 SCALE(x2
), SCALE(y2
/ 2));
949 xlcd_filltriangle(SCALE(x
), SCALE(ay
), SCALE(x
), SCALE(y
),
950 SCALE(x2
), SCALE((LCD_HEIGHT
*SIZE
) -
951 ((LCD_HEIGHT
*SIZE
) - y2
) / 2));
960 void chopper_load(bool newgame
)
967 iScreenX
= LCD_WIDTH
* SIZE
;
968 iScreenY
= LCD_HEIGHT
* SIZE
;
969 blockh
= iScreenY
/ 5;
970 blockw
= iScreenX
/ 20;
976 iPlayerPosY
= (iScreenY
* 4) / 10;
977 iLastBlockPlacedPosX
= 0;
978 iGravityTimerCountdown
= 2;
984 for (i
=0; i
< NUMBER_OF_PARTICLES
; i
++)
985 mParticles
[i
].bIsActive
= 0;
987 for (i
=0; i
< NUMBER_OF_BLOCKS
; i
++)
988 mBlocks
[i
].bIsActive
= 0;
991 chopClearTerrain(&mGround
);
993 for (i
=0; i
< MAX_TERRAIN_NODES
; i
++)
994 chopAddTerrainNode(&mGround
,i
* 30,g
- iR(0,20));
996 if (chopUpdateTerrainRecycling(&mGround
) == 1)
997 /* mirror the sky if we've changed the ground */
998 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
1000 iLevelMode
= LEVEL_MODE_NORMAL
;
1001 if (iLevelMode
== LEVEL_MODE_NORMAL
)
1002 /* make it a bit more exciting, cause it's easy terrain... */
1006 /* this is the plugin entry point */
1007 enum plugin_status
plugin_start(const void* parameter
)
1012 rb
->lcd_setfont(FONT_SYSFIXED
);
1014 rb
->lcd_set_backdrop(NULL
);
1016 #ifdef HAVE_LCD_COLOR
1017 rb
->lcd_set_background(LCD_BLACK
);
1018 rb
->lcd_set_foreground(LCD_WHITE
);
1021 /* Turn off backlight timeout */
1022 backlight_force_on(); /* backlight control in lib/helper.c */
1024 rb
->srand( *rb
->current_tick
);
1026 configfile_load(CFG_FILE
, config
, 1, 0);
1029 ret
= chopGameLoop();
1031 configfile_save(CFG_FILE
, config
, 1, 0);
1033 rb
->lcd_setfont(FONT_UI
);
1034 /* Turn on backlight timeout (revert to settings) */
1035 backlight_use_settings(); /* backlight control in lib/helper.c */