/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } drawTime += (float)gameTime.ElapsedGameTime.TotalSeconds; if (drawTime <= maxTime) { gameView.UpdateExplosion((float)gameTime.ElapsedGameTime.TotalSeconds); time += (float)gameTime.ElapsedGameTime.TotalSeconds; if (time >= (float)ss.ParticleLifeTime / (float)ss.MaxParticles) { //gameView.UpdateSmoke((float)gameTime.ElapsedGameTime.TotalSeconds); gameView.UpdateSmoke(drawTime); time = 0; } } else { drawTime = 0; gameView.Initiate(); } // TODO: Add your update logic here base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here MouseState newState = Mouse.GetState(); if (newState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released) { gameView.OnMouseClick((float)gameTime.ElapsedGameTime.TotalSeconds, new Vector2(newState.X, newState.Y)); } oldMouseState = newState; gameView.UpdateExplosion((float)gameTime.ElapsedGameTime.TotalSeconds); time += (float)gameTime.ElapsedGameTime.TotalSeconds; if (time >= (float)smokeSystem.ParticleLifeTime / (float)smokeSystem.MaxParticles) { gameView.UpdateSmoke(); time = 0; } base.Update(gameTime); }