/// <summary> /// Called 60 frames/per second and Draw all the /// sprites and other drawable images here /// </summary> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.LawnGreen); spriteBatch.Begin(); spriteBatch.Draw(backgroundImage, Vector2.Zero, Color.White); // Draw asteroids game shipSprite.Draw(spriteBatch); asteroidSprite.Draw(spriteBatch); // Draw Chase game playerSprite.Draw(spriteBatch); coinsController.Draw(spriteBatch); enemySprite.Draw(spriteBatch); DrawGameStatus(spriteBatch); DrawGameFooter(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public void Draw(RenderTarget target, RenderStates states) { float _temp = statemachine.CurrentState.Animation.PixelSize; PlayerSprite.Origin = new Vector2f(_temp / 2, _temp / 2); PlayerSprite.Position = Vector2fExtensions.toVector2f(body.Position); PlayerSprite.Rotation = MathHelper.ToDegrees(body.Rotation); PlayerSprite.Draw(target, states); }
/// <summary> /// Draw Player, enemy and coins /// </summary> public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { spriteBatch.Draw(backgroundImage, Vector2.Zero, Color.White); pauseButton.Draw(spriteBatch, gameTime); shipSprite.Draw(spriteBatch, gameTime); asteroidSprite.Draw(spriteBatch, gameTime); DrawGameStatus(spriteBatch); DrawGameFooter(spriteBatch); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); map.Draw(spriteBatch); player.Draw(gameTime); foreach (Collectable i in collectablesList) { i.Draw(gameTime); } //Displays time and score spriteBatch.DrawString(font, "Time Passed: " + Time.ToString("0.00"), new Vector2(140, 20), Color.Black); spriteBatch.DrawString(font, "Score: " + Score.ToString(), new Vector2(20, 20), Color.Black); spriteBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0); var spriteBatch = ScreenManager.SpriteBatch; float scrollSpeed = (float)_timer.Elapsed.TotalSeconds * -15.0f; Matrix transform = Matrix.CreateTranslation(scrollSpeed, 0, 0); spriteBatch.Begin(transformMatrix: transform); spriteBatch.Draw(_background, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero, 2.5f, SpriteEffects.None, 0); spriteBatch.End(); spriteBatch.Begin(); foreach (var obstacle in _obstacles) { obstacle.Draw(gameTime, spriteBatch); } _playerSprite.Draw(gameTime, spriteBatch); var textPositionX = ScreenManager.GraphicsDevice.Viewport.Width - ScreenManager.Font.MeasureString("High Score: XXXX").X - 2; if (_newHighScore) { spriteBatch.DrawString(_bangers, Math.Round(_timer.Elapsed.TotalSeconds, 1).ToString(), new Vector2(2, 2), Color.Green); spriteBatch.DrawString(_bangers, "High Score: " + Math.Round(_timer.Elapsed.TotalSeconds, 1), new Vector2(textPositionX, 2), Color.Green); } else { if (_highScore < _timer.Elapsed.TotalSeconds) { _newHighScore = true; } spriteBatch.DrawString(_bangers, Math.Round(_timer.Elapsed.TotalSeconds, 1).ToString(), new Vector2(2, 2), Color.White); spriteBatch.DrawString(_bangers, "High Score: " + Math.Round(_highScore, 1).ToString(), new Vector2(textPositionX, 2), Color.Yellow); } spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || _pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, _pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }
public override void Draw(GameTime gameTime) { SpriteBatch.Begin(); SpriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height), Color.White); player.Draw(SpriteBatch); // Drawing enemies foreach (var ennemi in enemies) { ennemi.Draw(SpriteBatch); } // Drawing stones foreach (var stone in preciousStones) { stone.Draw(SpriteBatch); } // Affichage du score Color score; if (player.Score > 0) { score = Color.LightGreen; } else { score = Color.OrangeRed; } SpriteBatch.DrawString(font, String.Format("Score : {0}", player.Score), Vector2.Zero, score); if (State == ScreenState.Pause) { SpriteBatch.Draw(pause, new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height), Color.White); string text = "Appuyez sur Escape pour continuer la partie..."; SpriteBatch.DrawString(font, text, new Vector2((Game.Window.ClientBounds.Width / 2) - (font.MeasureString(text).X / 2), 300), Color.Black, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } SpriteBatch.End(); }
/// <summary> /// Called 60 frames/per second and Draw all the /// sprites and other drawable images here /// </summary> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.LawnGreen); spriteBatch.Begin(); spriteBatch.Draw(backgroundImage, Vector2.Zero, Color.White); // Draw asteroids game shipSprite.Draw(spriteBatch); asteroidController.Draw(spriteBatch); // Draw Chase game coinsController.Draw(spriteBatch); DrawGameStatus(spriteBatch); DrawGameFooter(spriteBatch); if (state == GameStates.lost) { DrawGameLost(spriteBatch); } if (state == GameStates.won) { DrawGameWon(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }