Projectile - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Projectile

Hey anyone know how would I make an arrow move from the players current position towards the left(where it's positioned) if I know the player's current position. Note the player is already moving with opponentx-- and find the arrowx position that way.

opponentmovx--; //Moves player left;

arrowy=opponentmovy;

arrowx=opponentmovx;



See I compiled it and of course the arrow says in position with the opponent movements. How can I stop this. Thanks for any help.


Comments

  • : Hey anyone know how would I make an arrow move from the players current position towards the left(where it's positioned) if I know the player's current position. Note the player is already moving with opponentx-- and find the arrowx position that way.

    : opponentmovx--; //Moves player left;

    : arrowy=opponentmovy;

    : arrowx=opponentmovx;

    :

    : See I compiled it and of course the arrow says in position with the opponent movements. How can I stop this. Thanks for any help.

    :



    Come again? I don't understand what you're really asking here. I can calculate an arrow flying in the air's position. That's simple physics:



    Y+V0+(1/2AT^2)



    Y is the initial Y position, V0 is the initial velocity, A is the rate of acceleration, and T is time.



    If you were to calculate gravitational acceleration, you'd use -9.8m as the acceleration, assuming you're using metric.



    -Xotor-


  • Are you asking how to move a projectile?



    // MAKE BULLET APPEAR EX: if (Key == FIRE) MakeBullet();



    void MakeBullet()

    {

    for (i = 0; i < NumBullets; i++)

    if (!Bullets[i].Visible) /* If current bullet not visible, use as the new bullet */

    {

    Bullets[i].Visible = true; // Visible

    Bullets[i].X = Player.X + Player.W; // Initial X, Y

    Bullets[i].Y = Player.Y + 13;

    break; /* Exit, only need 1 bullet */

    }

    }



    // DETERMINE WHICH BULLETS ARE VISIBLE

    // MOVE AND DRAW VISIBLE BULLETS



    for (i = 0; i < NumBullets; i++)

    if (Bullets[i].X > WIDTH) // If current bullet off screen (WIDTH = Screen W)

    Bullets[i].Visible = false; // Not visible

    else // Else...

    {

    Bullets[i].Visible = true; // Visible

    Bullets[i].Move(RIGHT); // Move

    DrawImage(Images[BULLET], Bullets[i].X, Bullets[i].Y); // Draw

    }


Sign In or Register to comment.