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
This commit is contained in:
Teruaki Kawashima 2010-02-12 12:11:37 +00:00
parent 23ac6ffaa1
commit 6878cf34ef

View file

@ -205,7 +205,7 @@ static int iPlayerSpeedY;
static int iLastBlockPlacedPosX; static int iLastBlockPlacedPosX;
static int iGravityTimerCountdown; static int iGravityTimerCountdown;
static int iPlayerAlive; static int iPlayerAlive;
static int iLevelMode; static int iLevelMode, iCurrLevelMode;
static int blockh,blockw; static int blockh,blockw;
static int highscore; static int highscore;
static int score; static int score;
@ -261,7 +261,7 @@ struct CTerrain mRoof;
/*Function declarations*/ /*Function declarations*/
static void chopDrawParticle(struct CParticle *mParticle); static void chopDrawParticle(struct CParticle *mParticle);
static void chopDrawBlock(struct CBlock *mBlock); static void chopDrawBlock(struct CBlock *mBlock);
static void chopRenderTerrain(struct CTerrain *ter); static void chopRenderTerrain(struct CTerrain *ter, bool isground);
void chopper_load(bool newgame); void chopper_load(bool newgame);
void cleanup_chopper(void); void cleanup_chopper(void);
@ -385,7 +385,7 @@ int chopUpdateTerrainRecycling(struct CTerrain *ter)
v = 3*iPlayerSpeedX; v = 3*iPlayerSpeedX;
if(v>50) if(v>50)
v=50; v=50;
if(iLevelMode == LEVEL_MODE_STEEP) if(iCurrLevelMode == LEVEL_MODE_STEEP)
v*=5; v*=5;
chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v)); chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v));
@ -560,7 +560,7 @@ static int chopParticleOffscreen(struct CParticle *mParticle)
static void chopKillPlayer(void) static void chopKillPlayer(void)
{ {
int i, button; int i;
for (i = 0; i < NUMBER_OF_PARTICLES; i++) { for (i = 0; i < NUMBER_OF_PARTICLES; i++) {
mParticles[i].bIsActive = 0; mParticles[i].bIsActive = 0;
@ -571,10 +571,6 @@ static void chopKillPlayer(void)
iPlayerAlive--; iPlayerAlive--;
if (iPlayerAlive == 0) { if (iPlayerAlive == 0) {
rb->lcd_set_drawmode(DRMODE_FG);
#if LCD_DEPTH >= 2
rb->lcd_set_foreground(LCD_LIGHTGRAY);
#endif
rb->splash(HZ, "Game Over"); rb->splash(HZ, "Game Over");
if (score > highscore) { if (score > highscore) {
@ -584,36 +580,8 @@ static void chopKillPlayer(void)
highscore); highscore);
rb->splash(HZ*2, scoretext); rb->splash(HZ*2, scoretext);
} }
rb->splash(HZ/4, "Press " ACTIONTEXT " to continue");
rb->lcd_update();
rb->lcd_set_drawmode(DRMODE_SOLID);
while (true) {
button = rb->button_get(true);
if (button == ACTION
#ifdef ACTION2
|| button == ACTION2
#endif
) {
while (true) {
button = rb->button_get(true);
if (button == (ACTION | BUTTON_REL)
#ifdef ACTION2
|| button == (ACTION2 | BUTTON_REL)
#endif
) {
chopper_load(true);
return;
}
}
}
}
} else } else
chopper_load(false); chopper_load(false);
} }
static void chopDrawTheWorld(void) static void chopDrawTheWorld(void)
@ -648,8 +616,8 @@ static void chopDrawTheWorld(void)
i++; i++;
} }
chopRenderTerrain(&mGround); chopRenderTerrain(&mGround, true);
chopRenderTerrain(&mRoof); chopRenderTerrain(&mRoof, false);
} }
@ -676,6 +644,7 @@ static void chopDrawScene(void)
#elif LCD_DEPTH == 2 #elif LCD_DEPTH == 2
rb->lcd_set_background(LCD_WHITE); rb->lcd_set_background(LCD_WHITE);
#endif #endif
rb->lcd_clear_display();
chopDrawTheWorld(); chopDrawTheWorld();
chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY); chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY);
@ -750,6 +719,7 @@ static int chopMenu(int menunum)
#endif #endif
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
switch(rb->do_menu(&menu, &result, NULL, false)) switch(rb->do_menu(&menu, &result, NULL, false))
@ -818,7 +788,6 @@ static int chopGameLoop(void)
mParticles[i].iWorldY += mParticles[i].iSpeedY; mParticles[i].iWorldY += mParticles[i].iSpeedY;
} }
rb->lcd_clear_display();
/* Redraw the main window: */ /* Redraw the main window: */
chopDrawScene(); chopDrawScene();
@ -831,7 +800,7 @@ static int chopGameLoop(void)
chopAddParticle(iPlayerPosX, iPlayerPosY+5, 0, 0); chopAddParticle(iPlayerPosX, iPlayerPosY+5, 0, 0);
} }
if(iLevelMode == LEVEL_MODE_NORMAL) if(iCurrLevelMode == LEVEL_MODE_NORMAL)
chopGenerateBlockIfNeeded(); chopGenerateBlockIfNeeded();
@ -939,19 +908,13 @@ static void chopDrawBlock(struct CBlock *mBlock)
} }
static void chopRenderTerrain(struct CTerrain *ter) static void chopRenderTerrain(struct CTerrain *ter, bool isground)
{ {
int i = 1; int i = 1;
int oldx = 0; int oldx = 0;
int ay=0;
if(ter->mNodes[0].y < (LCD_HEIGHT*SIZE)/2)
ay=0;
else
ay=(LCD_HEIGHT*SIZE);
while(i < ter->iNodesCount && oldx < iScreenX) while(i < ter->iNodesCount && oldx < iScreenX)
{ {
@ -960,6 +923,19 @@ static void chopRenderTerrain(struct CTerrain *ter)
int x2 = ter->mNodes[i].x - iCameraPosX; int x2 = ter->mNodes[i].x - iCameraPosX;
int y2 = ter->mNodes[i].y; int y2 = ter->mNodes[i].y;
int ax, ay;
if ((y < y2) != isground)
{
ax = x2;
ay = y;
}
else
{
ax = x;
ay = y2;
}
#if LCD_DEPTH > 2 #if LCD_DEPTH > 2
rb->lcd_set_foreground(LCD_RGBPACK(100,255,100)); rb->lcd_set_foreground(LCD_RGBPACK(100,255,100));
#elif LCD_DEPTH == 2 #elif LCD_DEPTH == 2
@ -969,23 +945,24 @@ static void chopRenderTerrain(struct CTerrain *ter)
rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2)); rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2));
xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2), xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2),
SCALE(x2), SCALE(ay)); SCALE(ax), SCALE(ay));
xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x2), SCALE(y2),
SCALE(x2), SCALE(ay));
if (ay == 0) if (isground)
xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), {
SCALE(x2), SCALE(y2 / 2)); y = ay;
y2 = (LCD_HEIGHT*SIZE);
}
else else
xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), {
SCALE(x2), SCALE((LCD_HEIGHT*SIZE) - y = 0;
((LCD_HEIGHT*SIZE) - y2) / 2)); y2 = ay;
}
if (y2-y > 0)
rb->lcd_fillrect(SCALE(x), SCALE(y), SCALE(x2-x)+1, SCALE(y2-y)+1);
oldx = x; oldx = x;
i++; i++;
} }
} }
void chopper_load(bool newgame) void chopper_load(bool newgame)
@ -1000,6 +977,7 @@ void chopper_load(bool newgame)
blockh = iScreenY / 5; blockh = iScreenY / 5;
blockw = iScreenX / 20; blockw = iScreenX / 20;
iPlayerAlive = 1; iPlayerAlive = 1;
iCurrLevelMode = iLevelMode;
score = 0; score = 0;
} }
iRotorOffset = 0; iRotorOffset = 0;
@ -1028,7 +1006,7 @@ void chopper_load(bool newgame)
/* mirror the sky if we've changed the ground */ /* mirror the sky if we've changed the ground */
chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4)); chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));
if (iLevelMode == LEVEL_MODE_NORMAL) if (iCurrLevelMode == LEVEL_MODE_NORMAL)
/* make it a bit more exciting, cause it's easy terrain... */ /* make it a bit more exciting, cause it's easy terrain... */
iPlayerSpeedX *= 2; iPlayerSpeedX *= 2;
} }