summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-02-12 12:11:37 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-02-12 12:11:37 +0000
commit6878cf34ef36fdff95528718ca9d35764cc9374c (patch)
treebfa5730e63e84499430c9d31beaa1bb2214975d6
parent23ac6ffaa1efeea6417f7d064c0b8f4f280aa0cd (diff)
downloadrockbox-6878cf34ef36fdff95528718ca9d35764cc9374c.tar.gz
rockbox-6878cf34ef36fdff95528718ca9d35764cc9374c.zip
chopper: fix FS#11000: Drawing issue with steep mode. don't change level while in game.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24616 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/chopper.c100
1 files changed, 39 insertions, 61 deletions
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 66ce309275..c48e1a9951 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -205,7 +205,7 @@ static int iPlayerSpeedY;
205static int iLastBlockPlacedPosX; 205static int iLastBlockPlacedPosX;
206static int iGravityTimerCountdown; 206static int iGravityTimerCountdown;
207static int iPlayerAlive; 207static int iPlayerAlive;
208static int iLevelMode; 208static int iLevelMode, iCurrLevelMode;
209static int blockh,blockw; 209static int blockh,blockw;
210static int highscore; 210static int highscore;
211static int score; 211static int score;
@@ -261,7 +261,7 @@ struct CTerrain mRoof;
261/*Function declarations*/ 261/*Function declarations*/
262static void chopDrawParticle(struct CParticle *mParticle); 262static void chopDrawParticle(struct CParticle *mParticle);
263static void chopDrawBlock(struct CBlock *mBlock); 263static void chopDrawBlock(struct CBlock *mBlock);
264static void chopRenderTerrain(struct CTerrain *ter); 264static void chopRenderTerrain(struct CTerrain *ter, bool isground);
265void chopper_load(bool newgame); 265void chopper_load(bool newgame);
266void cleanup_chopper(void); 266void cleanup_chopper(void);
267 267
@@ -385,7 +385,7 @@ int chopUpdateTerrainRecycling(struct CTerrain *ter)
385 v = 3*iPlayerSpeedX; 385 v = 3*iPlayerSpeedX;
386 if(v>50) 386 if(v>50)
387 v=50; 387 v=50;
388 if(iLevelMode == LEVEL_MODE_STEEP) 388 if(iCurrLevelMode == LEVEL_MODE_STEEP)
389 v*=5; 389 v*=5;
390 390
391 chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v)); 391 chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v));
@@ -560,7 +560,7 @@ static int chopParticleOffscreen(struct CParticle *mParticle)
560 560
561static void chopKillPlayer(void) 561static void chopKillPlayer(void)
562{ 562{
563 int i, button; 563 int i;
564 564
565 for (i = 0; i < NUMBER_OF_PARTICLES; i++) { 565 for (i = 0; i < NUMBER_OF_PARTICLES; i++) {
566 mParticles[i].bIsActive = 0; 566 mParticles[i].bIsActive = 0;
@@ -571,10 +571,6 @@ static void chopKillPlayer(void)
571 iPlayerAlive--; 571 iPlayerAlive--;
572 572
573 if (iPlayerAlive == 0) { 573 if (iPlayerAlive == 0) {
574 rb->lcd_set_drawmode(DRMODE_FG);
575#if LCD_DEPTH >= 2
576 rb->lcd_set_foreground(LCD_LIGHTGRAY);
577#endif
578 rb->splash(HZ, "Game Over"); 574 rb->splash(HZ, "Game Over");
579 575
580 if (score > highscore) { 576 if (score > highscore) {
@@ -584,36 +580,8 @@ static void chopKillPlayer(void)
584 highscore); 580 highscore);
585 rb->splash(HZ*2, scoretext); 581 rb->splash(HZ*2, scoretext);
586 } 582 }
587
588 rb->splash(HZ/4, "Press " ACTIONTEXT " to continue");
589 rb->lcd_update();
590
591 rb->lcd_set_drawmode(DRMODE_SOLID);
592
593 while (true) {
594 button = rb->button_get(true);
595 if (button == ACTION
596#ifdef ACTION2
597 || button == ACTION2
598#endif
599 ) {
600 while (true) {
601 button = rb->button_get(true);
602 if (button == (ACTION | BUTTON_REL)
603#ifdef ACTION2
604 || button == (ACTION2 | BUTTON_REL)
605#endif
606 ) {
607 chopper_load(true);
608 return;
609 }
610 }
611 }
612 }
613
614 } else 583 } else
615 chopper_load(false); 584 chopper_load(false);
616
617} 585}
618 586
619static void chopDrawTheWorld(void) 587static void chopDrawTheWorld(void)
@@ -648,8 +616,8 @@ static void chopDrawTheWorld(void)
648 i++; 616 i++;
649 } 617 }
650 618
651 chopRenderTerrain(&mGround); 619 chopRenderTerrain(&mGround, true);
652 chopRenderTerrain(&mRoof); 620 chopRenderTerrain(&mRoof, false);
653 621
654} 622}
655 623
@@ -676,6 +644,7 @@ static void chopDrawScene(void)
676#elif LCD_DEPTH == 2 644#elif LCD_DEPTH == 2
677 rb->lcd_set_background(LCD_WHITE); 645 rb->lcd_set_background(LCD_WHITE);
678#endif 646#endif
647 rb->lcd_clear_display();
679 chopDrawTheWorld(); 648 chopDrawTheWorld();
680 chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY); 649 chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY);
681 650
@@ -750,6 +719,7 @@ static int chopMenu(int menunum)
750#endif 719#endif
751 720
752 rb->lcd_clear_display(); 721 rb->lcd_clear_display();
722 rb->button_clear_queue();
753 723
754 while (!menu_quit) { 724 while (!menu_quit) {
755 switch(rb->do_menu(&menu, &result, NULL, false)) 725 switch(rb->do_menu(&menu, &result, NULL, false))
@@ -818,7 +788,6 @@ static int chopGameLoop(void)
818 mParticles[i].iWorldY += mParticles[i].iSpeedY; 788 mParticles[i].iWorldY += mParticles[i].iSpeedY;
819 } 789 }
820 790
821 rb->lcd_clear_display();
822 /* Redraw the main window: */ 791 /* Redraw the main window: */
823 chopDrawScene(); 792 chopDrawScene();
824 793
@@ -831,7 +800,7 @@ static int chopGameLoop(void)
831 chopAddParticle(iPlayerPosX, iPlayerPosY+5, 0, 0); 800 chopAddParticle(iPlayerPosX, iPlayerPosY+5, 0, 0);
832 } 801 }
833 802
834 if(iLevelMode == LEVEL_MODE_NORMAL) 803 if(iCurrLevelMode == LEVEL_MODE_NORMAL)
835 chopGenerateBlockIfNeeded(); 804 chopGenerateBlockIfNeeded();
836 805
837 806
@@ -939,18 +908,12 @@ static void chopDrawBlock(struct CBlock *mBlock)
939} 908}
940 909
941 910
942static void chopRenderTerrain(struct CTerrain *ter) 911static void chopRenderTerrain(struct CTerrain *ter, bool isground)
943{ 912{
944 913
945 int i=1; 914 int i = 1;
946 915
947 int oldx=0; 916 int oldx = 0;
948
949 int ay=0;
950 if(ter->mNodes[0].y < (LCD_HEIGHT*SIZE)/2)
951 ay=0;
952 else
953 ay=(LCD_HEIGHT*SIZE);
954 917
955 while(i < ter->iNodesCount && oldx < iScreenX) 918 while(i < ter->iNodesCount && oldx < iScreenX)
956 { 919 {
@@ -960,6 +923,19 @@ static void chopRenderTerrain(struct CTerrain *ter)
960 923
961 int x2 = ter->mNodes[i].x - iCameraPosX; 924 int x2 = ter->mNodes[i].x - iCameraPosX;
962 int y2 = ter->mNodes[i].y; 925 int y2 = ter->mNodes[i].y;
926
927 int ax, ay;
928
929 if ((y < y2) != isground)
930 {
931 ax = x2;
932 ay = y;
933 }
934 else
935 {
936 ax = x;
937 ay = y2;
938 }
963#if LCD_DEPTH > 2 939#if LCD_DEPTH > 2
964 rb->lcd_set_foreground(LCD_RGBPACK(100,255,100)); 940 rb->lcd_set_foreground(LCD_RGBPACK(100,255,100));
965#elif LCD_DEPTH == 2 941#elif LCD_DEPTH == 2
@@ -969,23 +945,24 @@ static void chopRenderTerrain(struct CTerrain *ter)
969 rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2)); 945 rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2));
970 946
971 xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2), 947 xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2),
972 SCALE(x2), SCALE(ay)); 948 SCALE(ax), SCALE(ay));
973 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x2), SCALE(y2),
974 SCALE(x2), SCALE(ay));
975 949
976 if (ay == 0) 950 if (isground)
977 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), 951 {
978 SCALE(x2), SCALE(y2 / 2)); 952 y = ay;
953 y2 = (LCD_HEIGHT*SIZE);
954 }
979 else 955 else
980 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), 956 {
981 SCALE(x2), SCALE((LCD_HEIGHT*SIZE) - 957 y = 0;
982 ((LCD_HEIGHT*SIZE) - y2) / 2)); 958 y2 = ay;
959 }
960 if (y2-y > 0)
961 rb->lcd_fillrect(SCALE(x), SCALE(y), SCALE(x2-x)+1, SCALE(y2-y)+1);
983 962
984 oldx = x; 963 oldx = x;
985 i++; 964 i++;
986
987 } 965 }
988
989} 966}
990 967
991void chopper_load(bool newgame) 968void chopper_load(bool newgame)
@@ -1000,6 +977,7 @@ void chopper_load(bool newgame)
1000 blockh = iScreenY / 5; 977 blockh = iScreenY / 5;
1001 blockw = iScreenX / 20; 978 blockw = iScreenX / 20;
1002 iPlayerAlive = 1; 979 iPlayerAlive = 1;
980 iCurrLevelMode = iLevelMode;
1003 score = 0; 981 score = 0;
1004 } 982 }
1005 iRotorOffset = 0; 983 iRotorOffset = 0;
@@ -1028,7 +1006,7 @@ void chopper_load(bool newgame)
1028 /* mirror the sky if we've changed the ground */ 1006 /* mirror the sky if we've changed the ground */
1029 chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4)); 1007 chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));
1030 1008
1031 if (iLevelMode == LEVEL_MODE_NORMAL) 1009 if (iCurrLevelMode == LEVEL_MODE_NORMAL)
1032 /* make it a bit more exciting, cause it's easy terrain... */ 1010 /* make it a bit more exciting, cause it's easy terrain... */
1033 iPlayerSpeedX *= 2; 1011 iPlayerSpeedX *= 2;
1034} 1012}