Nevermind figured out what i was doing wrong myself have it working 
now thanks anyway
g




--- In [email protected], "glogic_1" <[EMAIL PROTECTED]> wrote:
>
> Hey all
> Im working on a simple 2d asteroids game at the moment. I have 
most 
> of it working but there is one part that aint working the way id 
> like. Basically whats happening is that when the up key(thrust) is 
> not being pressed that the ship should slow down to a stop. in the 
> direction it was going. Here is the code im using at the moment 
> using Borland Builder 6.
> struct vector{
>         float x;
>         float y;
> };
> 
> const int SHIP_NUM_POINTS=4; //number of points in ship's polygon
> struct Ship{
>         vector points[SHIP_NUM_POINTS]; //points of ship's polygon
>         vector position;
>         vector velocity;
>         vector direction;     // direction ship is currently 
pointing
>         //vector pos[SHIP_NUM_POINTS];
>         float rateOfAccel;      // how fast can we accelerate
>         float friction;         // how fast do we slow down
>         float rotation;         // how fast do we spin
>         int radius;             // the size of the circle which 
> contains the ship
>         bool alive;             // whether the ship is alive or 
dead
> }theShip;               
> 
> 
> the following is in a function to update the ship that is called 
> from a timer
> 
> else if(theKeys.up == false)
> {
>               if (ship.velocity.x > 0)
>               {
>                     ship.velocity.x = ship->velocity.x - .5;
>                     if (ship->velocity.x < 0)
>                     {
>                              ship->velocity.x = 0;
>                     }
>                }
>                else if (ship.velocity.x < 0)
>                {
>                      ship.velocity.x = ship->velocity.x + .5;
>                      if (ship->velocity.x > 0)
>                      {
>                             ship->velocity.x = 0;
>                       }
>                }
> 
> 
>                if (ship.velocity.y > 0)
>                {
>                       ship.velocity.y = ship->velocity.y - .5;
>                       if (ship->velocity.y < 0)
>                       {
>                             ship->velocity.y  = 0;
>                       }
>                }
>                else if (ship.velocity.y < 0)
>                {
>                       ship.velocity.y = ship->velocity.y + .5;
>                       if (ship->velocity.y > 0)
>                       {
>                                ship->velocity.y  = 0;
>                       }
>                }
> 
> 
> 
>         }
> 
> im trying to get the ships position to continue in the direction 
it 
> was going but just slow down.. this code does slow it down but 
> eventually one of the velocity co ordinates reaches 0 first which 
> makes the ship move while slowing down along that axis.. 
> not sure if ive given enough info to show what im trying to do so 
if 
> someone whats me to email the project to get a better 
understanding 
> let me know
> thanks
> g
>


Reply via email to