Removed several unnecessary (int)s and changed around operations to prevent problems with integer division.

Signed-off-by: onpon4 <onpon4@yahoo.com>
This commit is contained in:
onpon4 2012-03-14 11:54:48 -04:00
parent 0d189c858c
commit 38f44d9387
5 changed files with 20 additions and 20 deletions

View File

@ -38,7 +38,7 @@ static bool placeAlien(object *theEnemy)
if (currentGame.area == 24) if (currentGame.area == 24)
{ {
theEnemy->x = screen->w; 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++) for (int i = 0 ; i < MAX_ALIENS ; i++)
@ -396,8 +396,8 @@ static void getPreDefinedAliens()
if (currentGame.area == 5) if (currentGame.area == 5)
{ {
enemy[WC_BOSS].target = &player; enemy[WC_BOSS].target = &player;
enemy[WC_BOSS].x = (int)(-screen->w / 2); enemy[WC_BOSS].x = -screen->w / 2;
enemy[WC_BOSS].y = (int)(screen->h / 2); enemy[WC_BOSS].y = screen->h / 2;
enemy[13].owner = &enemy[WC_BOSS]; enemy[13].owner = &enemy[WC_BOSS];
enemy[13].target = &player; enemy[13].target = &player;
@ -412,8 +412,8 @@ static void getPreDefinedAliens()
else if ((currentGame.area == 11) || (currentGame.area == 14)) else if ((currentGame.area == 11) || (currentGame.area == 14))
{ {
enemy[WC_BOSS].target = &player; enemy[WC_BOSS].target = &player;
enemy[WC_BOSS].x = (int)(-screen->w / 2); enemy[WC_BOSS].x = -screen->w / 2;
enemy[WC_BOSS].y = (int)(screen->h / 2); enemy[WC_BOSS].y = screen->h / 2;
enemy[13].owner = &enemy[WC_BOSS]; enemy[13].owner = &enemy[WC_BOSS];
enemy[13].target = &player; enemy[13].target = &player;
@ -596,8 +596,8 @@ void initAliens()
{ {
enemy[WC_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE | FL_NOMOVE; enemy[WC_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE | FL_NOMOVE;
enemy[WC_KLINE].x = (int)(screen->w * (2 / 3)); enemy[WC_KLINE].x = (screen->w * 2) / 3;
enemy[WC_KLINE].y = (int)(screen->h / 2); enemy[WC_KLINE].y = screen->h / 2;
enemy[WC_KLINE].deathCounter = -250; enemy[WC_KLINE].deathCounter = -250;
enemy[WC_KLINE].maxShield = 1500; enemy[WC_KLINE].maxShield = 1500;

View File

@ -233,7 +233,7 @@ int mainGameLoop()
if (engine.paused) if (engine.paused)
{ {
textSurface(22, "PAUSED", -1, (int)(screen->h / 2), FONT_WHITE); textSurface(22, "PAUSED", -1, screen->h / 2, FONT_WHITE);
blitText(22); blitText(22);
updateScreen(); updateScreen();

View File

@ -503,8 +503,8 @@ int galaxyMap()
char string[25]; char string[25];
engine.cursor_x = (int)(screen->w / 2); engine.cursor_x = screen->w / 2;
engine.cursor_y = (int)(screen->h / 2); engine.cursor_y = screen->h / 2;
shape[0] = loadImage("gfx/cursor.png"); shape[0] = loadImage("gfx/cursor.png");
// Icons 1 - 29 // Icons 1 - 29

View File

@ -110,28 +110,28 @@ static void doTargetArrow()
// TODO: This is not very good. It assumes the player is always at (400,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 // 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. // 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; engine.targetArrow = 36;
if (distY > (int)(screen->h / 2)) if (distY > screen->h / 2)
engine.targetArrow = 40; engine.targetArrow = 40;
if (distX < (int)(-screen->w / 2)) if (distX < -screen->w / 2)
engine.targetArrow = 42; engine.targetArrow = 42;
if (distX > (int)(screen->w / 2)) if (distX > screen->w / 2)
engine.targetArrow = 38; 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; 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; 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; 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; engine.targetArrow = 43;
if (engine.targetArrow != -1) if (engine.targetArrow != -1)

View File

@ -28,8 +28,8 @@ Initialises the player for a new game.
void initPlayer() void initPlayer()
{ {
player.active = true; player.active = true;
player.x = (int)(screen->w / 2); player.x = screen->w / 2;
player.y = (int)(screen->h / 2); player.y = screen->h / 2;
player.speed = 2; player.speed = 2;
player.maxShield = (25 * currentGame.shieldUnits); player.maxShield = (25 * currentGame.shieldUnits);
player.systemPower = player.maxShield; player.systemPower = player.maxShield;