From 0d189c858cce80055b8f003c7afe7c2914a0b9d7 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 11 Mar 2012 23:16:56 -0400 Subject: [PATCH 1/3] Replaces many hard-coded numbers with references to screen->w and screen->h and adds the constants screenWidth, screenHeight, and viewBorder. This is a step towards supporting multiple resolutions. --- code/aliens.cpp | 36 ++++++++++++++++++------------------ code/defs.h | 5 +++++ code/game.cpp | 2 +- code/graphics.cpp | 4 ++-- code/init.cpp | 12 ++++++------ code/intermission.cpp | 19 ++++++++++--------- code/misc.cpp | 19 +++++++++++-------- code/missions.cpp | 10 +++++----- code/player.cpp | 14 +++++++------- code/script.cpp | 10 +++++----- code/title.cpp | 40 ++++++++++++++++++++-------------------- 11 files changed, 90 insertions(+), 81 deletions(-) diff --git a/code/aliens.cpp b/code/aliens.cpp index ef9df88..b79f6ba 100644 --- a/code/aliens.cpp +++ b/code/aliens.cpp @@ -26,19 +26,19 @@ object enemy[MAX_ALIENS]; static bool placeAlien(object *theEnemy) { if (rand() % 2 == 0) - theEnemy->x = rrand(800, 1600); + theEnemy->x = rrand(screen->w, screen->w * 2); else - theEnemy->x = rrand(-800, 0); + theEnemy->x = rrand(-screen->w, 0); if (rand() % 2 == 0) - theEnemy->y = rrand(600, 1200); + theEnemy->y = rrand(screen->h, screen->h * 2); else - theEnemy->y = rrand(-600, 0); + theEnemy->y = rrand(-screen->h, 0); if (currentGame.area == 24) { - theEnemy->x = 800; - theEnemy->y = rrand(200, 400); + theEnemy->x = screen->w; + theEnemy->y = rrand((int)((1/3) * screen->h), (int)((2/3) * screen->h)); } for (int i = 0 ; i < MAX_ALIENS ; i++) @@ -396,8 +396,8 @@ static void getPreDefinedAliens() if (currentGame.area == 5) { enemy[WC_BOSS].target = &player; - enemy[WC_BOSS].x = -400; - enemy[WC_BOSS].y = 300; + enemy[WC_BOSS].x = (int)(-screen->w / 2); + enemy[WC_BOSS].y = (int)(screen->h / 2); enemy[13].owner = &enemy[WC_BOSS]; enemy[13].target = &player; @@ -412,8 +412,8 @@ static void getPreDefinedAliens() else if ((currentGame.area == 11) || (currentGame.area == 14)) { enemy[WC_BOSS].target = &player; - enemy[WC_BOSS].x = -400; - enemy[WC_BOSS].y = 300; + enemy[WC_BOSS].x = (int)(-screen->w / 2); + enemy[WC_BOSS].y = (int)(screen->h / 2); enemy[13].owner = &enemy[WC_BOSS]; enemy[13].target = &player; @@ -475,14 +475,14 @@ static void addFriendly(int type) enemy[type].active = true; if (rand() % 2 == 0) - enemy[type].x = rrand(400, 550); + enemy[type].x = rrand((int)(screen->w / 2), (int)(screen->w / 2) + 150); else - enemy[type].x = rrand(250, 400); + enemy[type].x = rrand((int)(screen->w / 2) - 150, (int)(screen->w / 2)); if (rand() % 2 == 0) - enemy[type].y = rrand(300, 450); + enemy[type].y = rrand((int)(screen->h / 2), (int)(screen->h / 2) + 150); else - enemy[type].y = rrand(150, 300); + enemy[type].y = rrand((int)(screen->h / 2) - 150, (int)(screen->h / 2)); if (type == FR_PHOEBE) enemy[type].classDef = CD_PHOEBE; @@ -596,8 +596,8 @@ void initAliens() { enemy[WC_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE | FL_NOMOVE; - enemy[WC_KLINE].x = 600; - enemy[WC_KLINE].y = 300; + enemy[WC_KLINE].x = (int)(screen->w * (2 / 3)); + enemy[WC_KLINE].y = (int)(screen->h / 2); enemy[WC_KLINE].deathCounter = -250; enemy[WC_KLINE].maxShield = 1500; @@ -1188,7 +1188,7 @@ void doAliens() limitCharAdd(&theEnemy->hit, -1, 0, 100); - if ((theEnemy->x + theEnemy->image[0]->w > 0) && (theEnemy->x < 800) && (theEnemy->y + theEnemy->image[0]->h > 0) && (theEnemy->y < 600)) + if ((theEnemy->x + theEnemy->image[0]->w > 0) && (theEnemy->x < screen->w) && (theEnemy->y + theEnemy->image[0]->h > 0) && (theEnemy->y < screen->h)) { if ((!(theEnemy->flags & FL_DISABLED)) && (theEnemy->classDef != CD_ASTEROID) && (theEnemy->classDef != CD_ASTEROID2)) addEngine(theEnemy); @@ -1207,7 +1207,7 @@ void doAliens() else { theEnemy->shield--; - if ((theEnemy->x > 0) && (theEnemy->x < 800) && (theEnemy->y > 0) && (theEnemy->y < 600)) + if ((theEnemy->x > 0) && (theEnemy->x < screen->w) && (theEnemy->y > 0) && (theEnemy->y < screen->h)) { blit(theEnemy->image[theEnemy->face], (int)theEnemy->x, (int)theEnemy->y); addExplosion(theEnemy->x + (rand() % theEnemy->image[0]->w), theEnemy->y + (rand() % theEnemy->image[0]->h), E_BIG_EXPLOSION); diff --git a/code/defs.h b/code/defs.h index 8cc6d12..e093b2f 100644 --- a/code/defs.h +++ b/code/defs.h @@ -305,3 +305,8 @@ extern const char *systemNames[]; extern const char *systemBackground[]; static const signed char rate2reload[6] = {15, 15, 13, 11, 9, 7}; + +const int screenWidth = 800; +const int screenHeight = 600; + +const int viewBorder = 100; diff --git a/code/game.cpp b/code/game.cpp index e05332c..d1c9f2c 100644 --- a/code/game.cpp +++ b/code/game.cpp @@ -233,7 +233,7 @@ int mainGameLoop() if (engine.paused) { - textSurface(22, "PAUSED", -1, 300, FONT_WHITE); + textSurface(22, "PAUSED", -1, (int)(screen->h / 2), FONT_WHITE); blitText(22); updateScreen(); diff --git a/code/graphics.cpp b/code/graphics.cpp index 8260b00..8e79677 100644 --- a/code/graphics.cpp +++ b/code/graphics.cpp @@ -718,8 +718,8 @@ void doStarfield() else if (star[i].speed == 1) color = darkGrey; - wrapFloat(&(star[i].x += (engine.ssx * star[i].speed)), 0, 799); - wrapFloat(&(star[i].y += (engine.ssy * star[i].speed)), 0, 599); + wrapFloat(&(star[i].x += (engine.ssx * star[i].speed)), 0, screen->w - 1); + wrapFloat(&(star[i].y += (engine.ssy * star[i].speed)), 0, screen->h - 1); putpixel(screen, (int)star[i].x, (int)star[i].y, color); r.x = (int)star[i].x; diff --git a/code/init.cpp b/code/init.cpp index 31ce70e..28f052e 100644 --- a/code/init.cpp +++ b/code/init.cpp @@ -34,10 +34,10 @@ void initVars() { srand(time(NULL)); - for (int i = 0 ; i < 200 ; i++) + for (int i = 0 ; i < (int)(screen->w * screen->h / 2400) ; i++) { - star[i].x = rand() % 800; - star[i].y = rand() % 600; + star[i].x = rand() % screen->w; + star[i].y = rand() % screen->h; star[i].speed = 1 + (rand() % 3); } @@ -188,12 +188,12 @@ void initSystem() SDL_WM_SetIcon(loadImage("gfx/alienDevice.png"), NULL); if (engine.fullScreen) - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); + screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); else - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); + screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); if (screen == NULL) { - printf("Couldn't set 800x600x16 video mode: %s\n", SDL_GetError()); + printf("Couldn't set %ix%ix16 video mode: %s\n", screenWidth, screenHeight, SDL_GetError()); exit(1); } diff --git a/code/intermission.cpp b/code/intermission.cpp index e9322f9..ade8bff 100644 --- a/code/intermission.cpp +++ b/code/intermission.cpp @@ -34,8 +34,8 @@ static void doCursor() { getPlayerInput(); - limitInt(&engine.cursor_x, 10, 790); - limitInt(&engine.cursor_y, 10, 590); + limitInt(&engine.cursor_x, 10, screen->w - 10); + limitInt(&engine.cursor_y, 10, screen->h - 10); blit(shape[0], engine.cursor_x, engine.cursor_y); } @@ -442,7 +442,7 @@ static void showOptions(SDL_Surface *optionsSurface) #if LINUX SDL_WM_ToggleFullScreen(screen); #else - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); + screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); drawBackground(); flushBuffer(); #endif @@ -457,7 +457,7 @@ static void showOptions(SDL_Surface *optionsSurface) #if LINUX SDL_WM_ToggleFullScreen(screen); #else - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); + screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); drawBackground(); flushBuffer(); #endif @@ -503,7 +503,8 @@ int galaxyMap() char string[25]; - engine.cursor_x = engine.cursor_y = 500; + engine.cursor_x = (int)(screen->w / 2); + engine.cursor_y = (int)(screen->h / 2); shape[0] = loadImage("gfx/cursor.png"); // Icons 1 - 29 @@ -631,9 +632,9 @@ int galaxyMap() r.x = 0; r.y = 0; - r.h = 600; + r.h = screen->h; r.w = 1; - for (int i = 40 ; i < 800 ; i+= 40) + for (int i = 40 ; i < screen->w ; i+= 40) { r.x = i; SDL_FillRect(screen, &r, darkerBlue); @@ -642,8 +643,8 @@ int galaxyMap() r.x = 0; r.y = 0; r.h = 1; - r.w = 800; - for (int i = 40 ; i < 600 ; i+= 40) + r.w = screen->w; + for (int i = 40 ; i < screen->h ; i+= 40) { r.y = i; SDL_FillRect(screen, &r, darkerBlue); diff --git a/code/misc.cpp b/code/misc.cpp index 219ca54..f0e4ac5 100644 --- a/code/misc.cpp +++ b/code/misc.cpp @@ -107,28 +107,31 @@ static void doTargetArrow() int distX = (int)(enemy[engine.targetIndex].x - player.x); int distY = (int)(enemy[engine.targetIndex].y - player.y); - if (distY < -300) + // TODO: This is not very good. It assumes the player is always at (400,300), + // which is not always true, resulting in the arrows sometimes not appearing when + // the enemy is not visible and sometimes appearing when the enemy is visible. + if (distY < (int)(-screen->h / 2)) engine.targetArrow = 36; - if (distY > 300) + if (distY > (int)(screen->h / 2)) engine.targetArrow = 40; - if (distX < -400) + if (distX < (int)(-screen->w / 2)) engine.targetArrow = 42; - if (distX > 400) + if (distX > (int)(screen->w / 2)) engine.targetArrow = 38; - if ((distY < -300) && (distX > 400)) + if ((distY < (int)(-screen->h / 2)) && (distX > (int)(screen->w / 2))) engine.targetArrow = 37; - if ((distY > 300) && (distX > 400)) + if ((distY > (int)(screen->h / 2)) && (distX > (int)(screen->w / 2))) engine.targetArrow = 39; - if ((distY > 300) && (distX < -400)) + if ((distY > (int)(screen->h / 2)) && (distX < (int)(-screen->w / 2))) engine.targetArrow = 41; - if ((distY < -300) && (distX < -400)) + if ((distY < (int)(-screen->h / 2)) && (distX < (int)(-screen->w / 2))) engine.targetArrow = 43; if (engine.targetArrow != -1) diff --git a/code/missions.cpp b/code/missions.cpp index 6b92779..b0ef198 100644 --- a/code/missions.cpp +++ b/code/missions.cpp @@ -672,14 +672,14 @@ bool missionFailed() static void drawBriefScreen() { - SDL_Rect r = {0, 0, 800, 2}; + SDL_Rect r = {0, 0, screen->w, 2}; - for (int i = 0 ; i < 120 ; i++) + for (int i = 0 ; i < (int)(screen->h / 4) - 30 ; i++) { - r.y = (i * 2) + 60; + r.y = (i * 2) + 62; // Not a typo; a black gap is left in the middle if it's 60. + SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0)); + r.y = (screen->h - (i * 2) - 60); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0)); - r.y = (300 + (i * 2)); - SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, (120 - i), 0)); } blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00); diff --git a/code/player.cpp b/code/player.cpp index 7ef3c8f..2a390dd 100644 --- a/code/player.cpp +++ b/code/player.cpp @@ -28,8 +28,8 @@ Initialises the player for a new game. void initPlayer() { player.active = true; - player.x = 200; - player.y = 200; + player.x = (int)(screen->w / 2); + player.y = (int)(screen->h / 2); player.speed = 2; player.maxShield = (25 * currentGame.shieldUnits); player.systemPower = player.maxShield; @@ -217,8 +217,8 @@ void doPlayer() if (engine.done == 0) { - limitFloat(&player.x, 100, 700); - limitFloat(&player.y, 100, 500); + limitFloat(&player.x, viewBorder, screen->w - viewBorder); + limitFloat(&player.y, viewBorder, screen->h - viewBorder); } if (player.shield > engine.lowShield) @@ -362,9 +362,9 @@ void leaveSector() { player.x += engine.ssx; engine.ssx -= 1; - if (player.y > 300) + if (player.y > screen->h) player.y--; - if (player.y < 300) + if (player.y < screen->h) player.y++; } @@ -380,7 +380,7 @@ void leaveSector() player.face = 0; player.x += 12; engine.ssx -= 0.2; - if (player.x > 1600) + if (player.x > (2 * screen->w)) engine.done = 1; } } diff --git a/code/script.cpp b/code/script.cpp index 58e577b..1d49b88 100644 --- a/code/script.cpp +++ b/code/script.cpp @@ -272,14 +272,14 @@ void doCutscene(int scene) enemy[i].y += enemy[i].dy; enemy[i].x += engine.ssx; blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y); - if (enemy[i].x > 850) + if (enemy[i].x > (screen->w + 50)) { enemy[i].x = -50; - enemy[i].y = rand() % 560; + enemy[i].y = rand() % (screen->h - 40); } if (enemy[i].y < -50) - enemy[i].y = 650; - if (enemy[i].y > 650) + enemy[i].y = (screen->h + 50); + if (enemy[i].y > (screen->h + 50)) enemy[i].y = -50; } } @@ -308,7 +308,7 @@ void doCutscene(int scene) } if ((showMessage) && (messageBox != NULL)) - blit(messageBox, (800 - messageBox->w) / 2, 500); + blit(messageBox, (screen->w - messageBox->w) / 2, screen->h - 100); delayFrame(); diff --git a/code/title.cpp b/code/title.cpp index 9a170da..fa7bce3 100644 --- a/code/title.cpp +++ b/code/title.cpp @@ -171,11 +171,11 @@ int doTitle() prlogo = loadImage("gfx/prlogo.png"); sflogo = loadImage("gfx/sflogo.png"); - int prx = ((800 - prlogo->w) / 2); - int pry = ((600 - prlogo->h) / 2); + int prx = ((screen->w - prlogo->w) / 2); + int pry = ((screen->h - prlogo->h) / 2); - int sfx = ((800 - sflogo->w) / 2); - int sfy = ((600 - sflogo->h) / 2); + int sfx = ((screen->w - sflogo->w) / 2); + int sfy = ((screen->h - sflogo->h) / 2); textSurface(0, "PRESENTS", -1, 300, FONT_WHITE); textSurface(1, "AN SDL GAME", -1, 300, FONT_WHITE); @@ -205,8 +205,8 @@ int doTitle() enemy[i] = defEnemy[CD_TRANSPORTSHIP]; if ((rand() % 5) == 0) enemy[i] = defEnemy[CD_MINER]; - enemy[i].x = rand() % 800; - enemy[i].y = rand() % 560; + enemy[i].x = rand() % screen->w; + enemy[i].y = rand() % (screen->h - 40); enemy[i].dx = 1 + rand() % 3; enemy[i].face = 0; } @@ -258,7 +258,7 @@ int doTitle() if (enemy[i].x > 830) { enemy[i].x = -40; - enemy[i].y = rand() % 580; + enemy[i].y = rand() % (screen->h - 20); enemy[i].dx = 1 + rand() % 3; } } @@ -414,9 +414,9 @@ int doTitle() SDL_WM_ToggleFullScreen(screen); #else if (engine.fullScreen) - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); + screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN); else - screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); + screen = SDL_SetVideoMode(screen->w, screen->h, 0, SDL_DOUBLEBUF|SDL_HWPALETTE); drawBackground(); flushBuffer(); @@ -491,7 +491,7 @@ void showStory() { freeGraphics(); - int y = 620; + int y = screen->h + 20; FILE *fp; @@ -540,7 +540,7 @@ void showStory() if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE])) break; - if (textShape[8].y > 450) + if (textShape[8].y > (int)(screen->h / 2) + 150) { for (int i = 0 ; i < 9 ; i++) { @@ -585,8 +585,8 @@ void gameover() Mix_PlayMusic(engine.music, 1); } - int x = (800 - gameover->w) / 2; - int y = (600 - gameover->h) / 2; + int x = (screen->w - gameover->w) / 2; + int y = (screen->h - gameover->h) / 2; updateScreen(); @@ -603,8 +603,8 @@ void gameover() updateScreen(); unBuffer(); - x = ((800 - gameover->w) / 2) - rrand(-2, 2); - y = ((600 - gameover->h) / 2) - rrand(-2, 2); + x = ((screen->w - gameover->w) / 2) - rrand(-2, 2); + y = ((screen->h - gameover->h) / 2) - rrand(-2, 2); blit(gameover, x, y); delayFrame(); @@ -632,7 +632,7 @@ void doCredits() int lastCredit = 0; int yPos = 0; - int yPos2 = 600; + int yPos2 = screen->h; char text[255]; textObject *credit; @@ -665,7 +665,7 @@ void doCredits() { fscanf(fp, "%d %[^\n]%*c", &yPos, text); credit[i].image = textSurface(text, FONT_WHITE); - credit[i].x = (800 - credit[i].image->w) / 2; + credit[i].x = (screen->w - credit[i].image->w) / 2; yPos2 += yPos; credit[i].y = yPos2; } @@ -706,11 +706,11 @@ void doCredits() for (int i = 0 ; i < numberOfCredits ; i++) { - if ((credit[i].y > -10) && (credit[i].y < 610)) + if ((credit[i].y > -10) && (credit[i].y < (screen->h + 10))) blit(credit[i].image, (int)credit[i].x, (int)credit[i].y); - if (speed > 0 && credit[lastCredit].y > 400) + if (speed > 0 && credit[lastCredit].y > ((int)(screen->h / 2) + 100)) credit[i].y -= speed; - else if(speed < 0 && credit[0].y < 600) + else if(speed < 0 && credit[0].y < screen->h) credit[i].y -= speed; } From 38f44d93872daa2e5afc6e0af9db4446e93f92a3 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Wed, 14 Mar 2012 11:54:48 -0400 Subject: [PATCH 2/3] Removed several unnecessary (int)s and changed around operations to prevent problems with integer division. Signed-off-by: onpon4 --- code/aliens.cpp | 14 +++++++------- code/game.cpp | 2 +- code/intermission.cpp | 4 ++-- code/misc.cpp | 16 ++++++++-------- code/player.cpp | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/code/aliens.cpp b/code/aliens.cpp index b79f6ba..60c5cb1 100644 --- a/code/aliens.cpp +++ b/code/aliens.cpp @@ -38,7 +38,7 @@ static bool placeAlien(object *theEnemy) if (currentGame.area == 24) { theEnemy->x = screen->w; - theEnemy->y = rrand((int)((1/3) * screen->h), (int)((2/3) * screen->h)); + theEnemy->y = rrand(screen->h / 3, (2 * screen->h) / 3); } for (int i = 0 ; i < MAX_ALIENS ; i++) @@ -396,8 +396,8 @@ static void getPreDefinedAliens() if (currentGame.area == 5) { enemy[WC_BOSS].target = &player; - enemy[WC_BOSS].x = (int)(-screen->w / 2); - enemy[WC_BOSS].y = (int)(screen->h / 2); + enemy[WC_BOSS].x = -screen->w / 2; + enemy[WC_BOSS].y = screen->h / 2; enemy[13].owner = &enemy[WC_BOSS]; enemy[13].target = &player; @@ -412,8 +412,8 @@ static void getPreDefinedAliens() else if ((currentGame.area == 11) || (currentGame.area == 14)) { enemy[WC_BOSS].target = &player; - enemy[WC_BOSS].x = (int)(-screen->w / 2); - enemy[WC_BOSS].y = (int)(screen->h / 2); + enemy[WC_BOSS].x = -screen->w / 2; + enemy[WC_BOSS].y = screen->h / 2; enemy[13].owner = &enemy[WC_BOSS]; enemy[13].target = &player; @@ -596,8 +596,8 @@ void initAliens() { enemy[WC_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE | FL_NOMOVE; - enemy[WC_KLINE].x = (int)(screen->w * (2 / 3)); - enemy[WC_KLINE].y = (int)(screen->h / 2); + enemy[WC_KLINE].x = (screen->w * 2) / 3; + enemy[WC_KLINE].y = screen->h / 2; enemy[WC_KLINE].deathCounter = -250; enemy[WC_KLINE].maxShield = 1500; diff --git a/code/game.cpp b/code/game.cpp index d1c9f2c..45e8548 100644 --- a/code/game.cpp +++ b/code/game.cpp @@ -233,7 +233,7 @@ int mainGameLoop() if (engine.paused) { - textSurface(22, "PAUSED", -1, (int)(screen->h / 2), FONT_WHITE); + textSurface(22, "PAUSED", -1, screen->h / 2, FONT_WHITE); blitText(22); updateScreen(); diff --git a/code/intermission.cpp b/code/intermission.cpp index ade8bff..0a00dd9 100644 --- a/code/intermission.cpp +++ b/code/intermission.cpp @@ -503,8 +503,8 @@ int galaxyMap() char string[25]; - engine.cursor_x = (int)(screen->w / 2); - engine.cursor_y = (int)(screen->h / 2); + engine.cursor_x = screen->w / 2; + engine.cursor_y = screen->h / 2; shape[0] = loadImage("gfx/cursor.png"); // Icons 1 - 29 diff --git a/code/misc.cpp b/code/misc.cpp index f0e4ac5..ed9f1eb 100644 --- a/code/misc.cpp +++ b/code/misc.cpp @@ -110,28 +110,28 @@ static void doTargetArrow() // TODO: This is not very good. It assumes the player is always at (400,300), // which is not always true, resulting in the arrows sometimes not appearing when // the enemy is not visible and sometimes appearing when the enemy is visible. - if (distY < (int)(-screen->h / 2)) + if (distY < -screen->h / 2) engine.targetArrow = 36; - if (distY > (int)(screen->h / 2)) + if (distY > screen->h / 2) engine.targetArrow = 40; - if (distX < (int)(-screen->w / 2)) + if (distX < -screen->w / 2) engine.targetArrow = 42; - if (distX > (int)(screen->w / 2)) + if (distX > screen->w / 2) engine.targetArrow = 38; - if ((distY < (int)(-screen->h / 2)) && (distX > (int)(screen->w / 2))) + if ((distY < -screen->h / 2) && (distX > screen->w / 2)) engine.targetArrow = 37; - if ((distY > (int)(screen->h / 2)) && (distX > (int)(screen->w / 2))) + if ((distY > screen->h / 2) && (distX > screen->w / 2)) engine.targetArrow = 39; - if ((distY > (int)(screen->h / 2)) && (distX < (int)(-screen->w / 2))) + if ((distY > screen->h / 2) && (distX < -screen->w / 2)) engine.targetArrow = 41; - if ((distY < (int)(-screen->h / 2)) && (distX < (int)(-screen->w / 2))) + if ((distY < -screen->h / 2) && (distX < -screen->w / 2)) engine.targetArrow = 43; if (engine.targetArrow != -1) diff --git a/code/player.cpp b/code/player.cpp index 2a390dd..010b65c 100644 --- a/code/player.cpp +++ b/code/player.cpp @@ -28,8 +28,8 @@ Initialises the player for a new game. void initPlayer() { player.active = true; - player.x = (int)(screen->w / 2); - player.y = (int)(screen->h / 2); + player.x = screen->w / 2; + player.y = screen->h / 2; player.speed = 2; player.maxShield = (25 * currentGame.shieldUnits); player.systemPower = player.maxShield; From aae191ff0cd4d082466c214e824fba6a830bb881 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Wed, 14 Mar 2012 12:02:04 -0400 Subject: [PATCH 3/3] I missed a couple (int)s in last commit. This removes them. Signed-off-by: onpon4 --- code/title.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/title.cpp b/code/title.cpp index fa7bce3..911a17e 100644 --- a/code/title.cpp +++ b/code/title.cpp @@ -540,7 +540,7 @@ void showStory() if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE])) break; - if (textShape[8].y > (int)(screen->h / 2) + 150) + if (textShape[8].y > (screen->h / 2) + 150) { for (int i = 0 ; i < 9 ; i++) { @@ -708,7 +708,7 @@ void doCredits() { if ((credit[i].y > -10) && (credit[i].y < (screen->h + 10))) blit(credit[i].image, (int)credit[i].x, (int)credit[i].y); - if (speed > 0 && credit[lastCredit].y > ((int)(screen->h / 2) + 100)) + if (speed > 0 && credit[lastCredit].y > ((screen->h / 2) + 100)) credit[i].y -= speed; else if(speed < 0 && credit[0].y < screen->h) credit[i].y -= speed;