Projectile - Programmers Heaven

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Projectile

Guest
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.

• Guest
: 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-

• Guest
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

}