Fixed edges of the screen slowing you down.
And unlike a fix I previously did, this one is perfect. Rather than fiddling with ssx and ssy, I just added some new variables, smx and smy.
This commit is contained in:
parent
775be7afb4
commit
c404e3611e
|
@ -1219,9 +1219,9 @@ void doAliens()
|
|||
}
|
||||
|
||||
if ((currentGame.area != 18) || (theEnemy->shield < 0))
|
||||
theEnemy->x += engine.ssx;
|
||||
theEnemy->x += engine.ssx + engine.smx;
|
||||
|
||||
theEnemy->y += engine.ssy;
|
||||
theEnemy->y += engine.ssy + engine.smy;
|
||||
}
|
||||
|
||||
theEnemy++;
|
||||
|
|
|
@ -43,7 +43,7 @@ void addBullet(object *theWeapon, object *attacker, int y, int dy)
|
|||
{
|
||||
bullet->dx = theWeapon->speed;
|
||||
if ((currentGame.area == 18) || (currentGame.area == 24))
|
||||
bullet->dx += fabsf(engine.ssx);
|
||||
bullet->dx += fabsf(engine.ssx + engine.smx);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -556,8 +556,8 @@ void doBullets()
|
|||
bullet->target = NULL;
|
||||
}
|
||||
|
||||
bullet->x += engine.ssx;
|
||||
bullet->y += engine.ssy;
|
||||
bullet->x += engine.ssx + engine.smx;
|
||||
bullet->y += engine.ssy + engine.smy;
|
||||
|
||||
for (int i = 0 ; i < MAX_ALIENS ; i++)
|
||||
{
|
||||
|
|
|
@ -96,8 +96,8 @@ void doCargo()
|
|||
|
||||
blit(cargo[i].image[0], (int)cargo[i].x, (int)cargo[i].y);
|
||||
|
||||
cargo[i].x += engine.ssx;
|
||||
cargo[i].y += engine.ssy;
|
||||
cargo[i].x += engine.ssx + engine.smx;
|
||||
cargo[i].y += engine.ssy + engine.smy;
|
||||
|
||||
limitFloat(&cargo[i].x, cargo[i].owner->x - 50, cargo[i].owner->x + 50);
|
||||
limitFloat(&cargo[i].y, cargo[i].owner->y - 50, cargo[i].owner->y + 50);
|
||||
|
|
|
@ -242,8 +242,8 @@ void doCollectables()
|
|||
if ((collectable->x + collectable->image->w > 0) && (collectable->x < 800) && (collectable->y + collectable->image->h > 0) && (collectable->y < 600))
|
||||
blit(collectable->image, (int)collectable->x, (int)collectable->y);
|
||||
|
||||
collectable->x += engine.ssx;
|
||||
collectable->y += engine.ssy;
|
||||
collectable->x += engine.ssx + engine.smx;
|
||||
collectable->y += engine.ssy + engine.smx;
|
||||
collectable->x += collectable->dx;
|
||||
collectable->y += collectable->dy;
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ void doDebris()
|
|||
{
|
||||
debris->thinktime--;
|
||||
|
||||
debris->x += engine.ssx;
|
||||
debris->y += engine.ssy;
|
||||
debris->x += engine.ssx + engine.smx;
|
||||
debris->y += engine.ssy + engine.smy;
|
||||
debris->x += debris->dx;
|
||||
debris->y += debris->dy;
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ void doExplosions()
|
|||
|
||||
if (explosion->active)
|
||||
{
|
||||
explosion->x += engine.ssx;
|
||||
explosion->y += engine.ssy;
|
||||
explosion->x += engine.ssx + engine.smx;
|
||||
explosion->y += engine.ssy + engine.smy;
|
||||
|
||||
if (isOnScreen((int)explosion->x, (int)explosion->y, explosion->image[0]->w, explosion->image[0]->h))
|
||||
blit(explosion->image[0], (int)explosion->x, (int)explosion->y);
|
||||
|
|
|
@ -109,6 +109,8 @@ int mainGameLoop()
|
|||
|
||||
engine.ssx = 0;
|
||||
engine.ssy = 0;
|
||||
engine.smx = 0;
|
||||
engine.smy = 0;
|
||||
|
||||
engine.done = 0;
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ void defineGlobals()
|
|||
|
||||
engine.ssx = 0;
|
||||
engine.ssy = 0;
|
||||
engine.smx = 0;
|
||||
engine.smy = 0;
|
||||
|
||||
engine.bulletHead = new object;
|
||||
engine.bulletHead->next = NULL;
|
||||
|
|
|
@ -711,8 +711,10 @@ void doStarfield()
|
|||
else if (star[i].speed == 1)
|
||||
color = darkGrey;
|
||||
|
||||
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);
|
||||
wrapFloat(&(star[i].x += ((engine.ssx + engine.smx) * star[i].speed)), 0,
|
||||
screen->w - 1);
|
||||
wrapFloat(&(star[i].y += ((engine.ssy + engine.smy) * star[i].speed)), 0,
|
||||
screen->h - 1);
|
||||
|
||||
putpixel(screen, (int)star[i].x, (int)star[i].y, color);
|
||||
r.x = (int)star[i].x;
|
||||
|
|
|
@ -514,7 +514,8 @@ int galaxyMap()
|
|||
|
||||
engine.done = 0;
|
||||
engine.keyState[KEY_FIRE] = 0;
|
||||
engine.ssx = engine.ssy = 0;
|
||||
engine.ssx = 0;
|
||||
engine.ssy = 0;
|
||||
|
||||
SDL_Rect r;
|
||||
SDL_Rect destRect;
|
||||
|
|
|
@ -76,6 +76,9 @@ void doPlayer()
|
|||
engine.ssx *= 0.99;
|
||||
engine.ssy *= 0.99;
|
||||
|
||||
engine.smx = 0;
|
||||
engine.smy = 0;
|
||||
|
||||
int shapeToUse;
|
||||
|
||||
if (player.shield > -100)
|
||||
|
@ -190,8 +193,26 @@ void doPlayer()
|
|||
|
||||
if (engine.done == 0)
|
||||
{
|
||||
limitFloat(&player.x, viewBorder, screen->w - viewBorder);
|
||||
limitFloat(&player.y, viewBorder, screen->h - viewBorder);
|
||||
if (player.x < viewBorder)
|
||||
{
|
||||
engine.smx += viewBorder - player.x;
|
||||
player.x = viewBorder;
|
||||
}
|
||||
else if (player.x > screen->w - viewBorder)
|
||||
{
|
||||
engine.smx += (screen->w - viewBorder) - player.x;
|
||||
player.x = screen->w - viewBorder;
|
||||
}
|
||||
if (player.y < viewBorder)
|
||||
{
|
||||
engine.smy += viewBorder - player.y;
|
||||
player.y = viewBorder;
|
||||
}
|
||||
else if (player.y > screen->h - viewBorder)
|
||||
{
|
||||
engine.smy += (screen->h - viewBorder) - player.y;
|
||||
player.y = screen->h - viewBorder;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.shield > engine.lowShield)
|
||||
|
|
|
@ -189,6 +189,8 @@ void doCutscene(int scene)
|
|||
|
||||
engine.ssx = -0.5;
|
||||
engine.ssy = 0;
|
||||
engine.smx = 0;
|
||||
engine.smy = 0;
|
||||
|
||||
flushBuffer();
|
||||
freeGraphics();
|
||||
|
@ -253,7 +255,7 @@ void doCutscene(int scene)
|
|||
}
|
||||
enemy[i].x += enemy[i].dx;
|
||||
enemy[i].y += enemy[i].dy;
|
||||
enemy[i].x += engine.ssx;
|
||||
enemy[i].x += engine.ssx + engine.smx;
|
||||
blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
|
||||
if (enemy[i].x > (screen->w + 50))
|
||||
{
|
||||
|
|
|
@ -230,6 +230,8 @@ struct globalEngineVariables {
|
|||
|
||||
float ssx;
|
||||
float ssy;
|
||||
float smx;
|
||||
float smy;
|
||||
|
||||
Mix_Music *music;
|
||||
|
||||
|
|
|
@ -217,6 +217,8 @@ int doTitle()
|
|||
// Set the star motion
|
||||
engine.ssx = -0.5;
|
||||
engine.ssy = 0;
|
||||
engine.smx = 0;
|
||||
engine.smy = 0;
|
||||
|
||||
int then = SDL_GetTicks();
|
||||
int now;
|
||||
|
|
Loading…
Reference in New Issue