• Create Account

### #ActualAndy474

Posted 17 August 2012 - 07:22 AM

your best bet is to use vectors.
Your bullet come out of the gun at a certain velocity, so for instance:
Vector2 bulletVelocity = Vector2.Transform(new Vector2(-bulletPower),0), Matrix.CreateRotationZ(turretRotation));
//rotates the bullet coming out of the turret.


this will make the bullet zip across the screen in a linear fashion, to make that parabolic effect, addGravity:

void updateBullet() {
Gravity = new Vector2(0, -9.837f);
bulletVelocity += Gravity;
}


http://www.riemers.n...rp/series2d.php this article talks about and the type of game your making, thats c# using XNA, same principal can be applied to java though.

### #2Andy474

Posted 17 August 2012 - 07:20 AM

your best bet is to use vectors.
Your bullet come out of the gun at a certain velocity, so for instance:
Vector2 bulletVelocity = Vector2.Transform(new Vector2(-bulletPower),0), Matrix.CreateRotationZ(turretRotation));
//rotates the bullet coming out of the turret.


this will make the bullet zip across the screen in a linear fashion, to make that parabolic effect, addGravity:

void updateBullet() {
Gravity = new Vector2(0, -9.837f);
bulletVelocity += Gravity;
}


http://www.riemers.n...rp/series2d.php article talks about and the type of game your making, not sure on language but thats c# using XNA, same principal can be applied to any language.

### #1Andy474

Posted 17 August 2012 - 07:19 AM

your best bet is to use vectors.
Your bullet come out of the gun at a certain velocity, so for instance:
[code lang="c#"]
Vector2 bulletVelocity = Vector2.Transform(new Vector2(-bulletPower),0), Matrix.CreateRotationZ(turretRotation));
//rotates the bullet coming out of the turret.
[/code]
this will make the bullet zip across the screen in a linear fashion, to make that parabolic effect, addGravity:
void updateBullet() {
Gravity = new Vector2(0, -9.837f);
bulletVelocity += Gravity;
}

http://www.riemers.net/eng/Tutorials/XNA/Csharp/series2d.php article talks about and the type of game your making, not sure on language but thats c# using XNA, same principal can be applied to any language.

PARTNERS