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 #define QUIT BUTTON_POWER
75 #define ACTION BUTTON_SELECT
76 #define ACTIONTEXT "SELECT"
78 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
79 #define QUIT BUTTON_HOME
80 #define ACTION BUTTON_SELECT
81 #define ACTIONTEXT "SELECT"
83 #elif CONFIG_KEYPAD == GIGABEAT_PAD
84 #define QUIT BUTTON_MENU
85 #define ACTION BUTTON_SELECT
86 #define ACTIONTEXT "SELECT"
88 #elif CONFIG_KEYPAD == RECORDER_PAD
89 #define QUIT BUTTON_OFF
90 #define ACTION BUTTON_PLAY
91 #define ACTIONTEXT "PLAY"
93 #elif CONFIG_KEYPAD == ONDIO_PAD
94 #define QUIT BUTTON_OFF
95 #define ACTION BUTTON_UP
96 #define ACTION2 BUTTON_MENU
97 #define ACTIONTEXT "UP"
99 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
100 #define QUIT BUTTON_BACK
101 #define ACTION BUTTON_SELECT
102 #define ACTION2 BUTTON_MENU
103 #define ACTIONTEXT "SELECT"
105 #elif CONFIG_KEYPAD == MROBE100_PAD
106 #define QUIT BUTTON_POWER
107 #define ACTION BUTTON_SELECT
108 #define ACTIONTEXT "SELECT"
110 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
111 #define QUIT BUTTON_RC_REC
112 #define ACTION BUTTON_RC_PLAY
113 #define ACTION2 BUTTON_RC_MODE
114 #define ACTIONTEXT "PLAY"
116 #elif CONFIG_KEYPAD == COWON_D2_PAD
117 #define QUIT BUTTON_POWER
118 #define ACTION2 BUTTON_PLUS
120 #elif CONFIG_KEYPAD == IAUDIO67_PAD
121 #define QUIT BUTTON_POWER
122 #define ACTION BUTTON_PLAY
123 #define ACTION2 BUTTON_STOP
124 #define ACTIONTEXT "PLAY"
126 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
127 #define QUIT BUTTON_BACK
128 #define ACTION BUTTON_UP
129 #define ACTION2 BUTTON_MENU
130 #define ACTIONTEXT "UP"
132 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
133 #define QUIT BUTTON_POWER
134 #define ACTION BUTTON_MENU
135 #define ACTION2 BUTTON_SELECT
136 #define ACTIONTEXT "MENU"
138 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
139 #define QUIT BUTTON_POWER
140 #define ACTION BUTTON_MENU
141 #define ACTION2 BUTTON_PLAY
142 #define ACTIONTEXT "MENU"
144 #elif CONFIG_KEYPAD == ONDAVX747_PAD || \
145 CONFIG_KEYPAD == ONDAVX777_PAD || \
146 CONFIG_KEYPAD == MROBE500_PAD
147 #define QUIT BUTTON_POWER
149 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
150 #define QUIT BUTTON_LEFT
151 #define ACTION BUTTON_RIGHT
152 #define ACTIONTEXT "RIGHT"
154 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
155 #define QUIT BUTTON_REC
156 #define ACTION BUTTON_PLAY
157 #define ACTION2 BUTTON_UP
158 #define ACTIONTEXT "PLAY"
160 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
161 #define QUIT (BUTTON_REC|BUTTON_PLAY)
162 #define ACTION BUTTON_SELECT
163 #define ACTIONTEXT "SELECT"
166 #error No keymap defined!
169 #ifdef HAVE_TOUCHSCREEN
171 #define QUIT BUTTON_TOPLEFT
174 #define ACTION BUTTON_BOTTOMLEFT
177 #define ACTION2 BUTTON_BOTTOMRIGHT
180 #define ACTIONTEXT "BOTTOMRIGHT"
184 #define NUMBER_OF_BLOCKS 8
185 #define NUMBER_OF_PARTICLES 3
186 #define MAX_TERRAIN_NODES 15
188 #define LEVEL_MODE_NORMAL 0
189 #define LEVEL_MODE_STEEP 1
193 static inline int SCALE(int x
)
195 return x
== 1 ? x
: x
>> 1;
204 /* in 10 milisecond (ticks) */
205 #define CYCLETIME ((CYCLES*HZ)/1000)
207 /*Chopper's local variables to track the terrain position etc*/
208 static int chopCounter
;
209 static int iRotorOffset
;
212 static int iPlayerPosX
;
213 static int iPlayerPosY
;
214 static int iCameraPosX
;
215 static int iPlayerSpeedX
;
216 static int iPlayerSpeedY
;
217 static int iLastBlockPlacedPosX
;
218 static int iGravityTimerCountdown
;
219 static int iPlayerAlive
;
220 static int iLevelMode
, iCurrLevelMode
;
221 static int blockh
,blockw
;
222 static int highscore
;
225 #define CFG_FILE "chopper.cfg"
226 #define MAX_POINTS 50000
227 static struct configdata config
[] =
229 {TYPE_INT
, 0, MAX_POINTS
, { .int_p
= &highscore
}, "highscore", NULL
}
262 struct CTerrainNode mNodes
[MAX_TERRAIN_NODES
];
264 int iLastNodePlacedPosX
;
267 struct CBlock mBlocks
[NUMBER_OF_BLOCKS
];
268 struct CParticle mParticles
[NUMBER_OF_PARTICLES
];
270 struct CTerrain mGround
;
271 struct CTerrain mRoof
;
273 /*Function declarations*/
274 static void chopDrawParticle(struct CParticle
*mParticle
);
275 static void chopDrawBlock(struct CBlock
*mBlock
);
276 static void chopRenderTerrain(struct CTerrain
*ter
, bool isground
);
277 void chopper_load(bool newgame
);
278 void cleanup_chopper(void);
280 static void chopDrawPlayer(int x
,int y
) /* These are SCREEN coords, not world!*/
284 rb
->lcd_set_foreground(LCD_RGBPACK(50,50,200));
286 rb
->lcd_set_foreground(LCD_DARKGRAY
);
288 rb
->lcd_fillrect(SCALE(x
+6), SCALE(y
+2), SCALE(12), SCALE(9));
289 rb
->lcd_fillrect(SCALE(x
-3), SCALE(y
+6), SCALE(20), SCALE(3));
292 rb
->lcd_set_foreground(LCD_RGBPACK(50,50,50));
294 rb
->lcd_set_foreground(LCD_DARKGRAY
);
296 rb
->lcd_fillrect(SCALE(x
+10), SCALE(y
), SCALE(2), SCALE(3));
297 rb
->lcd_fillrect(SCALE(x
+10), SCALE(y
), SCALE(1), SCALE(3));
300 rb
->lcd_set_foreground(LCD_RGBPACK(40,40,100));
302 rb
->lcd_set_foreground(LCD_BLACK
);
304 rb
->lcd_drawline(SCALE(x
), SCALE(y
+iRotorOffset
), SCALE(x
+20),
305 SCALE(y
-iRotorOffset
));
308 rb
->lcd_set_foreground(LCD_RGBPACK(20,20,50));
310 rb
->lcd_set_foreground(LCD_BLACK
);
312 rb
->lcd_fillrect(SCALE(x
- 2), SCALE(y
+ 5), SCALE(2), SCALE(5));
316 static void chopClearTerrain(struct CTerrain
*ter
)
318 ter
->iNodesCount
= 0;
322 int iR(int low
,int high
)
324 return low
+rb
->rand()%(high
-low
+1);
327 static void chopCopyTerrain(struct CTerrain
*src
, struct CTerrain
*dest
,
328 int xOffset
,int yOffset
)
332 while(i
< src
->iNodesCount
)
334 dest
->mNodes
[i
].x
= src
->mNodes
[i
].x
+ xOffset
;
335 dest
->mNodes
[i
].y
= src
->mNodes
[i
].y
+ yOffset
;
340 dest
->iNodesCount
= src
->iNodesCount
;
341 dest
->iLastNodePlacedPosX
= src
->iLastNodePlacedPosX
;
345 static void chopAddTerrainNode(struct CTerrain
*ter
, int x
, int y
)
349 if(ter
->iNodesCount
+ 1 >= MAX_TERRAIN_NODES
)
351 /* DEBUGF("ERROR: Not enough nodes!\n"); */
357 i
= ter
->iNodesCount
- 1;
359 ter
->mNodes
[i
].x
= x
;
362 ter
->iLastNodePlacedPosX
= x
;
366 static void chopTerrainNodeDeleteAndShift(struct CTerrain
*ter
,int nodeIndex
)
370 while( i
< ter
->iNodesCount
)
372 ter
->mNodes
[i
- 1] = ter
->mNodes
[i
];
381 int chopUpdateTerrainRecycling(struct CTerrain
*ter
)
386 while(i
< ter
->iNodesCount
)
389 if( iCameraPosX
> ter
->mNodes
[i
].x
)
392 chopTerrainNodeDeleteAndShift(ter
,i
);
394 iNewNodePos
= ter
->iLastNodePlacedPosX
+ 50;
400 if(iCurrLevelMode
== LEVEL_MODE_STEEP
)
403 chopAddTerrainNode(ter
,iNewNodePos
,g
- iR(-v
,v
));
415 int chopTerrainHeightAtPoint(struct CTerrain
*ter
, int pX
)
418 int iNodeIndexOne
=0,iNodeIndexTwo
=0, h
, terY1
, terY2
, terX1
, terX2
, a
, b
;
422 for(i
=1;i
<MAX_TERRAIN_NODES
;i
++)
424 if(ter
->mNodes
[i
].x
> pX
)
426 iNodeIndexOne
= i
- 1;
432 iNodeIndexTwo
= iNodeIndexOne
+ 1;
433 terY1
= ter
->mNodes
[iNodeIndexOne
].y
;
434 terY2
= ter
->mNodes
[iNodeIndexTwo
].y
;
437 terX2
= ter
->mNodes
[iNodeIndexTwo
].x
- ter
->mNodes
[iNodeIndexOne
].x
;
439 pX
-= ter
->mNodes
[iNodeIndexOne
].x
;
452 int chopPointInTerrain(struct CTerrain
*ter
, int pX
, int pY
, int iTestType
)
454 int h
= chopTerrainHeightAtPoint(ter
, pX
);
462 static void chopAddBlock(int x
,int y
,int sx
,int sy
, int indexOverride
)
466 if(indexOverride
< 0)
468 while(mBlocks
[i
].bIsActive
&& i
< NUMBER_OF_BLOCKS
)
470 if(i
==NUMBER_OF_BLOCKS
)
472 DEBUGF("No blocks!\n");
479 mBlocks
[i
].bIsActive
= 1;
480 mBlocks
[i
].iWorldX
= x
;
481 mBlocks
[i
].iWorldY
= y
;
482 mBlocks
[i
].iSizeX
= sx
;
483 mBlocks
[i
].iSizeY
= sy
;
485 iLastBlockPlacedPosX
= x
;
488 static void chopAddParticle(int x
,int y
,int sx
,int sy
)
492 while(mParticles
[i
].bIsActive
&& i
< NUMBER_OF_PARTICLES
)
495 if(i
==NUMBER_OF_PARTICLES
)
498 mParticles
[i
].bIsActive
= 1;
499 mParticles
[i
].iWorldX
= x
;
500 mParticles
[i
].iWorldY
= y
;
501 mParticles
[i
].iSpeedX
= sx
;
502 mParticles
[i
].iSpeedY
= sy
;
505 static void chopGenerateBlockIfNeeded(void)
508 int DistSpeedX
= iPlayerSpeedX
* 5;
509 if(DistSpeedX
<200) DistSpeedX
= 200;
511 while(i
< NUMBER_OF_BLOCKS
)
513 if(!mBlocks
[i
].bIsActive
)
517 iX
= iLastBlockPlacedPosX
+ (350-DistSpeedX
);
521 sY
= blockh
+ iR(1,blockh
/3);
523 chopAddBlock(iX
,iY
,sX
,sY
,i
);
531 static int chopBlockCollideWithPlayer(struct CBlock
*mBlock
)
533 int px
= iPlayerPosX
;
534 int py
= iPlayerPosY
;
536 int x
= mBlock
->iWorldX
-17;
537 int y
= mBlock
->iWorldY
-11;
539 int x2
= x
+ mBlock
->iSizeX
+17;
540 int y2
= y
+ mBlock
->iSizeY
+11;
553 static int chopBlockOffscreen(struct CBlock
*mBlock
)
555 if(mBlock
->iWorldX
+ mBlock
->iSizeX
< iCameraPosX
)
561 static int chopParticleOffscreen(struct CParticle
*mParticle
)
563 if (mParticle
->iWorldX
< iCameraPosX
|| mParticle
->iWorldY
< 0 ||
564 mParticle
->iWorldY
> iScreenY
|| mParticle
->iWorldX
> iCameraPosX
+
573 static void chopKillPlayer(void)
577 for (i
= 0; i
< NUMBER_OF_PARTICLES
; i
++) {
578 mParticles
[i
].bIsActive
= 0;
579 chopAddParticle(iPlayerPosX
+ iR(0,20), iPlayerPosY
+ iR(0,20),
585 if (iPlayerAlive
== 0) {
586 rb
->splash(HZ
, "Game Over");
588 if (score
> highscore
) {
591 rb
->snprintf(scoretext
, sizeof(scoretext
), "New High Score: %d",
593 rb
->splash(HZ
*2, scoretext
);
599 static void chopDrawTheWorld(void)
603 while(i
< NUMBER_OF_BLOCKS
)
605 if(mBlocks
[i
].bIsActive
)
607 if(chopBlockOffscreen(&mBlocks
[i
]) == 1)
608 mBlocks
[i
].bIsActive
= 0;
610 chopDrawBlock(&mBlocks
[i
]);
618 while(i
< NUMBER_OF_PARTICLES
)
620 if(mParticles
[i
].bIsActive
)
622 if(chopParticleOffscreen(&mParticles
[i
]) == 1)
623 mParticles
[i
].bIsActive
= 0;
625 chopDrawParticle(&mParticles
[i
]);
631 chopRenderTerrain(&mGround
, true);
632 chopRenderTerrain(&mRoof
, false);
636 static void chopDrawParticle(struct CParticle
*mParticle
)
639 int iPosX
= (mParticle
->iWorldX
- iCameraPosX
);
640 int iPosY
= (mParticle
->iWorldY
);
642 rb
->lcd_set_foreground(LCD_RGBPACK(192,192,192));
644 rb
->lcd_set_foreground(LCD_LIGHTGRAY
);
646 rb
->lcd_fillrect(SCALE(iPosX
), SCALE(iPosY
), SCALE(3), SCALE(3));
650 static void chopDrawScene(void)
655 rb
->lcd_set_background(LCD_BLACK
);
657 rb
->lcd_set_background(LCD_WHITE
);
659 rb
->lcd_clear_display();
661 chopDrawPlayer(iPlayerPosX
- iCameraPosX
, iPlayerPosY
);
663 score
= -20 + iPlayerPosX
/3;
666 rb
->lcd_set_drawmode(DRMODE_COMPLEMENT
);
668 rb
->lcd_set_drawmode(DRMODE_FG
);
672 rb
->lcd_set_foreground(LCD_BLACK
);
674 rb
->lcd_set_foreground(LCD_WHITE
);
678 rb
->snprintf(s
, sizeof(s
), "Dist: %d", score
);
680 rb
->snprintf(s
, sizeof(s
), "Distance: %d", score
);
682 rb
->lcd_getstringsize(s
, &w
, NULL
);
683 rb
->lcd_putsxy(2, 2, s
);
684 if (score
< highscore
)
688 rb
->snprintf(s
, sizeof(s
), "Hi: %d", highscore
);
690 rb
->snprintf(s
, sizeof(s
), "Best: %d", highscore
);
692 rb
->lcd_getstringsize(s
, &w2
, NULL
);
693 if (LCD_WIDTH
- 2 - w2
> w
+ 2)
694 rb
->lcd_putsxy(LCD_WIDTH
- 2 - w2
, 2, s
);
696 rb
->lcd_set_drawmode(DRMODE_SOLID
);
702 static int chopMenuCb(int action
, const struct menu_item_ex
*this_item
)
704 if(action
== ACTION_REQUEST_MENUITEM
705 && !_ingame
&& ((intptr_t)this_item
)==0)
706 return ACTION_EXIT_MENUITEM
;
709 static int chopMenu(int menunum
)
713 bool menu_quit
= false;
715 static const struct opt_items levels
[2] = {
720 MENUITEM_STRINGLIST(menu
,"Chopper Menu",chopMenuCb
,
721 "Resume Game","Start New Game",
722 "Level","Playback Control","Quit");
723 _ingame
= (menunum
!=0);
725 #ifdef HAVE_LCD_COLOR
726 rb
->lcd_set_foreground(LCD_WHITE
);
727 rb
->lcd_set_background(LCD_BLACK
);
729 rb
->lcd_set_foreground(LCD_BLACK
);
730 rb
->lcd_set_background(LCD_WHITE
);
733 rb
->lcd_clear_display();
734 rb
->button_clear_queue();
737 switch(rb
->do_menu(&menu
, &result
, NULL
, false))
739 case 0: /* Resume Game */
743 case 1: /* Start New Game */
749 rb
->set_option("Level", &iLevelMode
, INT
, levels
, 2, NULL
);
752 playback_control(NULL
);
758 case MENU_ATTACHED_USB
:
760 res
= PLUGIN_USB_CONNECTED
;
764 rb
->lcd_clear_display();
768 static int chopGameLoop(void)
770 int move_button
, ret
;
772 int end
, i
=0, bdelay
=0, last_button
=BUTTON_NONE
;
774 if (chopUpdateTerrainRecycling(&mGround
) == 1)
775 /* mirror the sky if we've changed the ground */
776 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
786 end
= *rb
->current_tick
+ CYCLETIME
;
788 if(chopUpdateTerrainRecycling(&mGround
) == 1)
789 /* mirror the sky if we've changed the ground */
790 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
792 iRotorOffset
= iR(-1,1);
794 /* We need to have this here so particles move when we're dead */
796 for (i
=0; i
< NUMBER_OF_PARTICLES
; i
++)
797 if(mParticles
[i
].bIsActive
== 1)
799 mParticles
[i
].iWorldX
+= mParticles
[i
].iSpeedX
;
800 mParticles
[i
].iWorldY
+= mParticles
[i
].iSpeedY
;
803 /* Redraw the main window: */
807 iGravityTimerCountdown
--;
809 if(iGravityTimerCountdown
<= 0)
811 iGravityTimerCountdown
= 3;
812 chopAddParticle(iPlayerPosX
, iPlayerPosY
+5, 0, 0);
815 if(iCurrLevelMode
== LEVEL_MODE_NORMAL
)
816 chopGenerateBlockIfNeeded();
819 move_button
=rb
->button_status();
820 if (rb
->button_get(false) == QUIT
) {
825 last_button
= BUTTON_NONE
;
826 move_button
= BUTTON_NONE
;
829 switch (move_button
) {
834 if (last_button
!= ACTION
836 && last_button
!= ACTION2
845 if (last_button
== ACTION
847 || last_button
== ACTION2
854 if (rb
->default_event_handler(move_button
) == SYS_USB_CONNECTED
)
855 return PLUGIN_USB_CONNECTED
;
858 last_button
= move_button
;
861 iPlayerSpeedY
= bdelay
;
863 } else if (bdelay
> 0) {
864 iPlayerSpeedY
= bdelay
;
868 iCameraPosX
= iPlayerPosX
- 25;
869 iPlayerPosX
+= iPlayerSpeedX
;
870 iPlayerPosY
+= iPlayerSpeedY
;
873 /* increase speed as we go along */
874 if (chopCounter
== 100){
879 if (iPlayerPosY
> iScreenY
-10 || iPlayerPosY
< -5 ||
880 chopPointInTerrain(&mGround
, iPlayerPosX
, iPlayerPosY
+ 10, 0) ||
881 chopPointInTerrain(&mRoof
, iPlayerPosX
,iPlayerPosY
, 1))
890 for (i
=0; i
< NUMBER_OF_BLOCKS
; i
++)
891 if(mBlocks
[i
].bIsActive
== 1)
892 if(chopBlockCollideWithPlayer(&mBlocks
[i
])) {
900 if (TIME_BEFORE(*rb
->current_tick
, end
))
901 rb
->sleep(end
- *rb
->current_tick
); /* wait until time is over */
909 static void chopDrawBlock(struct CBlock
*mBlock
)
911 int iPosX
= (mBlock
->iWorldX
- iCameraPosX
);
912 int iPosY
= (mBlock
->iWorldY
);
914 rb
->lcd_set_foreground(LCD_RGBPACK(100,255,100));
916 rb
->lcd_set_foreground(LCD_BLACK
);
918 rb
->lcd_fillrect(SCALE(iPosX
), SCALE(iPosY
), SCALE(mBlock
->iSizeX
),
919 SCALE(mBlock
->iSizeY
));
923 static void chopRenderTerrain(struct CTerrain
*ter
, bool isground
)
930 while(i
< ter
->iNodesCount
&& oldx
< iScreenX
)
933 int x
= ter
->mNodes
[i
-1].x
- iCameraPosX
;
934 int y
= ter
->mNodes
[i
-1].y
;
936 int x2
= ter
->mNodes
[i
].x
- iCameraPosX
;
937 int y2
= ter
->mNodes
[i
].y
;
941 if ((y
< y2
) != isground
)
952 rb
->lcd_set_foreground(LCD_RGBPACK(100,255,100));
954 rb
->lcd_set_foreground(LCD_DARKGRAY
);
957 rb
->lcd_drawline(SCALE(x
), SCALE(y
), SCALE(x2
), SCALE(y2
));
959 xlcd_filltriangle(SCALE(x
), SCALE(y
), SCALE(x2
), SCALE(y2
),
960 SCALE(ax
), SCALE(ay
));
965 y2
= (LCD_HEIGHT
*SIZE
);
973 rb
->lcd_fillrect(SCALE(x
), SCALE(y
), SCALE(x2
-x
)+1, SCALE(y2
-y
)+1);
980 void chopper_load(bool newgame
)
987 iScreenX
= LCD_WIDTH
* SIZE
;
988 iScreenY
= LCD_HEIGHT
* SIZE
;
989 blockh
= iScreenY
/ 5;
990 blockw
= iScreenX
/ 20;
992 iCurrLevelMode
= iLevelMode
;
997 iPlayerPosY
= (iScreenY
* 4) / 10;
998 iLastBlockPlacedPosX
= 0;
999 iGravityTimerCountdown
= 2;
1005 for (i
=0; i
< NUMBER_OF_PARTICLES
; i
++)
1006 mParticles
[i
].bIsActive
= 0;
1008 for (i
=0; i
< NUMBER_OF_BLOCKS
; i
++)
1009 mBlocks
[i
].bIsActive
= 0;
1012 chopClearTerrain(&mGround
);
1014 for (i
=0; i
< MAX_TERRAIN_NODES
; i
++)
1015 chopAddTerrainNode(&mGround
,i
* 30,g
- iR(0,20));
1017 if (chopUpdateTerrainRecycling(&mGround
) == 1)
1018 /* mirror the sky if we've changed the ground */
1019 chopCopyTerrain(&mGround
, &mRoof
, 0, - ( (iScreenY
* 3) / 4));
1021 if (iCurrLevelMode
== LEVEL_MODE_NORMAL
)
1022 /* make it a bit more exciting, cause it's easy terrain... */
1026 /* this is the plugin entry point */
1027 enum plugin_status
plugin_start(const void* parameter
)
1032 rb
->lcd_setfont(FONT_SYSFIXED
);
1034 rb
->lcd_set_backdrop(NULL
);
1036 #ifdef HAVE_LCD_COLOR
1037 rb
->lcd_set_background(LCD_BLACK
);
1038 rb
->lcd_set_foreground(LCD_WHITE
);
1041 /* Turn off backlight timeout */
1042 backlight_force_on(); /* backlight control in lib/helper.c */
1044 rb
->srand( *rb
->current_tick
);
1046 configfile_load(CFG_FILE
, config
, 1, 0);
1049 ret
= chopGameLoop();
1051 configfile_save(CFG_FILE
, config
, 1, 0);
1053 rb
->lcd_setfont(FONT_UI
);
1054 /* Turn on backlight timeout (revert to settings) */
1055 backlight_use_settings(); /* backlight control in lib/helper.c */