public ProjectileSprite(Texture2D textureImage, Vector2 position, int collisionOffset, float speed, Vector2 offset, float scale, float rotation, List <Texture2D> textures) : base(textureImage, position, collisionOffset, speed, offset, scale) { this.rotation = rotation; engine = new ParticleEngine(textures, Vector2.Zero); }
public void Update(Vector3 direction, CollisionEngine collisionEngine, SoundEngine soundEngine, ParticleEngine particleEngine,List<Asteroid> asteroids, List<Powerup> powerups, MouseState originalMouseState, GameTime gameTime, GraphicsDevice device) { if (this.Shrink != null) { if (this.Shrink.Activated) { this.Shrink.Update(gameTime); if (this.Shrink.Timer <= 0) { this.Shrink = null; this.BoundingSphere = new BoundingSphere( this.Position, this.BoundingSphere.Radius / 0.25f); soundEngine.Grow.Play(); } else { this.BoundingSphere = new BoundingSphere( this.Position, this.BoundingSphere.Radius * 0.25f); } } } CheckCollisions(collisionEngine, soundEngine, powerups, asteroids); if (this.Destroyed) { if (this.Lives == 0) return; else { particleEngine.AddParticle(gameTime, this.Position); UpdatePosition(new Vector3(0, 0, 0)); this.Destroyed = false; this.Speed = 0f; this.Velocity = Vector3.Zero; this.Rotation = Quaternion.Identity; } } ProcessKeyboard(direction, gameTime, soundEngine); ProcessMouse(originalMouseState, gameTime, device); }
private void CheckCollisions(CollisionEngine collisionEngine, SoundEngine soundEngine, ParticleEngine particleEngine, GameTime gameTime, List<Asteroid> asteroids) { // Destroy the torpedo if it hits the edge of the universe if (collisionEngine.CollidesWithEdge(this.Position, this.BoundingSphere)) { if (soundEngine.Explosion.State != SoundState.Playing) soundEngine.Explosion.Play(); this.Destroyed = true; particleEngine.AddParticle(gameTime, this.Position); } // Destroy the torpedo if it hits an asteroid foreach (Asteroid asteroid in asteroids) { if (collisionEngine.CollideTwoObjects(this.BoundingSphere, asteroid.BoundingSphere)) { particleEngine.AddParticle(gameTime, this.Position); this.Destroyed = true; break; } } }
public void Update(CollisionEngine collisionEngine, SoundEngine soundEngine, ParticleEngine particleEngine, GameTime gameTime, List<Asteroid> asteroids) { CheckCollisions(collisionEngine, soundEngine, particleEngine, gameTime, asteroids); float speed = VELOCITY_CONST / gameTime.ElapsedGameTime.Milliseconds; Vector3 velocity = speed * this.Direction; Vector3 newPos = this.Position + velocity; UpdatePosition(newPos); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; Mouse.SetPosition(device.Viewport.Width / 2, device.Viewport.Height / 2); originalMouseState = Mouse.GetState(); billboardEffect = this.Content.Load<Effect>("Shaders/billboard_effect"); camera = new Camera(device); lifeTexture = this.Content.Load<Texture2D>("Sprites/spaceship_sprite"); explosionParticleTexture = this.Content.Load<Texture2D>("Sprites/explosion_particle"); shieldSprite = this.Content.Load<Texture2D>("Sprites/power_up_shield"); shrinkSprite = this.Content.Load<Texture2D>("Sprites/power_up_shrink"); timeFont = Content.Load<SpriteFont>("Fonts/Courier New"); collisionEngine = new CollisionEngine(); particleEngine = new ParticleEngine(explosionParticleTexture, billboardEffect, device); soundEngine = new SoundEngine(this.Content); skybox = new Skybox(); skybox.LoadModel(this.Content, effect); spaceship = new Spaceship(); spaceship.LoadModelAndTexture(this.Content, effect); torpedoes = new List<Torpedo>(); powerups = new List<Powerup>(); LoadAsteroids(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("Font"); List<Texture2D> textures = new List<Texture2D>(); textures.Add(Content.Load<Texture2D>("circle")); textures.Add(Content.Load<Texture2D>("star")); textures.Add(Content.Load<Texture2D>("diamond")); particleEngine = new ParticleEngine(textures, new Vector2(400, 200)); }