protected override void Update(GameTime gameTime) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; // Get time elapsed since last Update iteration KeyboardHandler(); // Handle keyboard input if (gameOver) { avatar.dX = 0; avatar.dY = 0; fire.dX = 0; fire.dY = 0; fire.dA = 0; } // Stop all movement when the game ends if (gameOver) { avatar.dX = 0; avatar.dY = 0; fire.dX = 0; fire.dY = 0; fire.dA = 0; } // Update animated SpriteClass objects based on their current rates of change avatar.Update(elapsedTime); fire.Update(elapsedTime); // Accelerate the Avatar downward each frame to simulate gravity. avatar.dY += gravitySpeed; // Set game floor if (avatar.y > screenHeight * SKYRATIO) { avatar.dY = 0; avatar.y = screenHeight * SKYRATIO; } // Set right edge if (avatar.x > screenWidth - avatar.texture.Width / 2) { avatar.x = screenWidth - avatar.texture.Width / 2; avatar.dX = 0; } // Set left edge if (avatar.x < 0 + avatar.texture.Width / 2) { avatar.x = 0 + avatar.texture.Width / 2; avatar.dX = 0; } // If the fire goes offscreen, spawn a new one and iterate the score if (fire.y > screenHeight + 100 || fire.y < -100 || fire.x > screenWidth + 100 || fire.x < -100) { SpawnFire(); score++; } if (avatar.RectangleCollision(fire)) { gameOver = true; } //if (avatar.RectangleCollision(fire)) gameOver = true; // End game if the Avatar collides with the fire base.Update(gameTime); }