Took me about 5 minutes, also, BLUE FIRE! :D
Here's how I did it:
In the UpdateExplosions I added a camera offset, Which I should of done instead of creating a new sprite engine, oh well I like this one better, it's a lot more sexier.
Here's the code:
private void UpdateExplosions(float dt)
{
KeyboardState keyboardState = Keyboard.GetState();
timeTillExplosion -= dt;
float ExplosionX = Game_Player.position.X;
float ExplosionY = Game_Player.position.Y - 26.0f;
// Set the location of the gun
if (GlobalVaribles.BuildDirection == "Left")
{
ExplosionX -= 46.0f;
}
// If we hit the Z key (Add "if (timeTillExplosion < 0 && keyboardState.IsKeyDown(Keys.Z))" if you want a timer)
if (keyboardState.IsKeyDown(Keys.Z))
{
Vector2 ExplosionLOC = new Vector2(ExplosionX, ExplosionY);
ExplosionLOC.X -= level.cameraPositionXAxis;
ExplosionLOC.Y -= level.cameraPositionYAxis;
// the overall explosion effect is actually comprised of two particle
// systems: the fiery bit, and the smoke behind it. add particles to
// both of those systems.
explosion.AddParticles(ExplosionLOC);
smoke.AddParticles(ExplosionLOC);
// reset the timer.
//timeTillExplosion = TimeBetweenExplosions;
}
}
I off set by ExplosionLOC.X -= level.cameraPositionXAxis; the camera value is a FLOAT so if you wanted to do it for a tile you would have to divide by your tile size, as with everything that you want to run with your tile system.
No comments:
Post a Comment