public override void InitializeParticleProperties(DefaultSpriteParticle cParticle) { cParticle.Lifetime = DPSFHelper.RandomNumberBetween(.5f, 1); cParticle.Position = Emitter.PositionData.Position; float randomVelocity = DPSFHelper.RandomNumberBetween(-200, 200); currentRotation += (float)Math.PI / 20; Vector2 rotatedRandomVector = TankGame.rotateVector(new Vector2(randomVelocity, randomVelocity), currentRotation); cParticle.Velocity = new Vector3(rotatedRandomVector.X, rotatedRandomVector.Y, 0); cParticle.Width = DPSFHelper.RandomNumberBetween(2, 6); cParticle.Height = DPSFHelper.RandomNumberBetween(2, 12); cParticle.Rotation = currentRotation; //Vector3 sVelocityMin = new Vector3(-100, 25, -100); //Vector3 sVelocityMax = new Vector3(100, 50, 100); //cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax); //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation); cParticle.StartColor = startColor; cParticle.EndColor = endColor; }
public void UpdateParticleVelocity(DPSFDefaultBaseParticle cParticle, float fElapsedTimeInSeconds) { currentRotation += (float)Math.PI / 4; Vector2 rotatedRandomVector = TankGame.rotateVector(originalVector, currentRotation); cParticle.Velocity = new Vector3(rotatedRandomVector.X * 800, rotatedRandomVector.Y * 800, 0); }
public override void InitializeParticleProperties(DefaultSpriteParticle cParticle) { cParticle.Lifetime = DPSFHelper.RandomNumberBetween(.1f, lifeTime / 2); cParticle.Position = Emitter.PositionData.Position; currentRotation += (float)Math.PI / 10; Vector2 rotatedRandomVector = TankGame.rotateVector(originalVector, currentRotation); cParticle.Velocity = new Vector3(rotatedRandomVector.X * 60, rotatedRandomVector.Y * 60, 0); cParticle.Size = DPSFHelper.RandomNumberBetween(1, 4); cParticle.Rotation = currentRotation; cParticle.StartColor = Color.Yellow; cParticle.EndColor = Color.Red; cParticle.Friction = DPSFHelper.RandomNumberBetween(50, 200); }
public void scatter() { if (scatterTime >= 1) { damage = 10; for (int i = 0; i < 8; i++) { scatterDirection = TankGame.rotateVector(bulletDirection, scatterAngle); scatterShots.Add(new Shots((TankGame)Game, this.position, scatterDirection * new Vector2(TankGame.GRAVITY * 10 + .25f, -TankGame.GRAVITY * 10 - .25f))); scatterAngle += (float)Math.PI / 7; Game.Components.Add(scatterShots[i]); } if (position.Y < 200) { speed = new Vector2(0, TankGame.GRAVITY * mass * 40); } else if (position.Y < 800) { speed = new Vector2(0, TankGame.GRAVITY * mass * 20); } else { speed = Vector2.Zero; } scattered = true; bulletCollided(); } }
public void move(GameTime time) { terrainMovement(); if (keyState.IsKeyDown(Keys.A) || controller.ThumbSticks.Left.X < 0) { if (collideLeft) { if (tankPosition.X > 0) { tankPosition.X += speedLeft; if (timer >= 15.0f) { ((TankGame)Game).soundManager.tankMove.Play(); } if (currentTankState == TankState.Downhill) { makeDirtTrail(new Vector2(tankRect.Right - dirtTrailOffset - 5, tankRect.Bottom - 26), TankGame.rotateVector(new Vector2(-1, 1), -26.3f)); } else if (currentTankState == TankState.Uphill) { makeDirtTrail(new Vector2(tankRect.Right - dirtTrailOffset + 10, tankRect.Bottom - 5), TankGame.rotateVector(new Vector2(-1, 1), .5f)); } else if (currentTankState == TankState.Normal) { makeDirtTrail(new Vector2(tankRect.Right - dirtTrailOffset + 5, tankRect.Bottom), new Vector2(-1, 1)); } } moveLimit -= (float)time.ElapsedGameTime.TotalSeconds; } } if (keyState.IsKeyDown(Keys.D) || controller.ThumbSticks.Left.X > 0) { if (collideRight) { if (tankPosition.X < 1920) { tankPosition.X += speedRight; if (timer >= 15.0f) { ((TankGame)Game).soundManager.tankMove.Play(); } if (currentTankState == TankState.Downhill) { makeDirtTrail(new Vector2(tankRect.Left + dirtTrailOffset - 5, tankRect.Bottom), TankGame.rotateVector(new Vector2(2, 1), -.95f)); } else if (currentTankState == TankState.Uphill) { makeDirtTrail(new Vector2(tankRect.Left + dirtTrailOffset + 10, tankRect.Bottom - 25), TankGame.rotateVector(new Vector2(1, .7f), 19.8f)); } else if (currentTankState == TankState.Normal) { makeDirtTrail(new Vector2(tankRect.Left + dirtTrailOffset + 5, tankRect.Bottom), new Vector2(1, 1)); } } moveLimit -= (float)time.ElapsedGameTime.TotalSeconds; } } if (timer >= 15.0f) { timer = 0.0f; } timer++; }