protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(); //Depth Level 0: spriteBatch.Draw(galaxyBackground, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White); //Depth Level 1: spriteBatch.Draw(galaxyStars, new Rectangle(-backgroundPadding + (int)(offset.X / (backgroundPadding / 10)), -backgroundPadding + (int)(offset.Y / (backgroundPadding / 10)), GraphicsDevice.Viewport.Width + (backgroundPadding * 2), GraphicsDevice.Viewport.Height + (backgroundPadding * 2)), Color.White); //Depth Level 2: spriteBatch.Draw(asteroidTexture, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (asteroidSize / 2) + (int)offset.X, (GraphicsDevice.Viewport.Height / 2) - (asteroidSize / 2) + (int)offset.Y, asteroidSize, asteroidSize), Color.White); Tile.drawTiles(spriteBatch); Tile.setTileOverlay(Mouse.GetState(), spriteBatch); spriteBatch.Draw(Player.shipTexture[Player.imageID], new Rectangle(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2, Player.size[0], Player.size[1]), null, Color.White, Player.rotation, new Vector2(110, 269), SpriteEffects.None, 0F); Projectile.drawProjectiles(spriteBatch); Enemy.drawEnemies(spriteBatch); ActiveKeyframeEffect.drawKeyframeEffects(spriteBatch); GUI.drawGold(spriteBatch, displayFont); GUI.drawButtons(spriteBatch); Minimap.drawMinimap(spriteBatch); if (GUI.paused) { spriteBatch.Draw(GUI.pausedOverlay, screenBounds, Color.White); } handleRepairModeDraw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
//Play audio in update /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (!GUI.paused) { handleRepairMode(); //Update Player Player.controller(Keyboard.GetState(), gameTime); Player.movement(); Player.initializeCollisionPoints(); //Update Mouse Input Player.mouseController(Mouse.GetState()); //Update Tile Rectangles Tile.updateTileRectangles(); //Update TEST ENEMY Enemy.updateEnemies(gameTime); //Update Defense Tiles Tile.updateDefenseTiles(gameTime); //Update Triggered Buttons GUI.updateButtons(); //Update Projectiles Projectile.movement(); //Checks if player is dead if (Player.dead) { handlePlayerDeath(); } //Update Keyframes ActiveKeyframeEffect.updateActiveKeyframeEffects(); //Update Turn Check checkTurn(); } else { //Only checks mouse clicks and updates buttons //Update Mouse Input Player.mouseController(Mouse.GetState()); //Update Triggered Buttons GUI.updateButtons(); //Asks if exit button has been pressed if (GUI.GUIButtons[7].triggered) { this.Exit(); } } base.Update(gameTime); }