protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.White); //Update coords using collision tracker class obstacleGenerator.AllObstacles = CollisionTracker.currObstacles; projectileGenerator.ActiveProjectiles = CollisionTracker.currProjectiles; // TODO: Add your drawing code here _spriteBatch.Begin(); background.Draw(ref _spriteBatch); background2.Draw(ref _spriteBatch); obstacleGenerator.Draw(ref _spriteBatch); _spriteBatch.DrawString(mainFont, "Welcome to AI-test Enviroment: Space-Ship.", new Vector2(wWidth / (float)4, 25), Color.Black); _spriteBatch.DrawString(largerMfont, "Score : " + projectileCollisionTracker.TotalCollisions, startPos, Color.Black); _spriteBatch.DrawString(largerMfont, "Checks : " + projectileCollisionTracker.totalChecks, new Vector2(0, 30), Color.Black); _spriteBatch.DrawString(largerMfont, "Fails : " + fails, new Vector2(0, 60), Color.Black); _spriteBatch.DrawString(mainFont, "Time : " + gameTime.TotalGameTime.TotalSeconds, new Vector2(600, 10), Color.Black); shipSprite.Draw(ref _spriteBatch); projectileGenerator.Draw(ref _spriteBatch); _spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.SetRenderTarget(renderTarget); graphics.GraphicsDevice.Clear(Defaults.SpaceBlue); spriteBatch.Begin(); if (CurrentScreen == Screen.Gameplay) { currentBackground.Draw(spriteBatch); GamePlayScreen.Draw(spriteBatch); } if (Fade.ShowingFade) { Fade.Draw(spriteBatch); } spriteBatch.End(); graphics.GraphicsDevice.SetRenderTarget(null); graphics.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, ScreenWidth, ScreenHeight), Color.White); spriteBatch.End(); base.Draw(gameTime); }
public virtual void Draw(SpriteBatch spriteBatch) { if (!Loaded) { return; } _background.Draw(spriteBatch); }
void canvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) { if (FirstDraw) { FirstDraw = false; BeforeFirstDraw(); } BackgroundImage.Draw(args.DrawingSession); BackgroundTaskStatus.Draw(args.DrawingSession); }
public void DrawWorld(SpriteBatch spritebatch) { background.Draw(spritebatch); for (int x = 0; x < blockArray.GetLength(0); x++) { for (int y = 0; y < blockArray.GetLength(1); y++) { if (blockArray[x, y] != null) { blockArray[x, y].Draw(spritebatch); } } } portals.ForEach(p => p.Draw(spritebatch)); enemies.ForEach(e => e.Draw(spritebatch)); }
//Main game loop, should be fired 60 times per second void canvas_DrawAnimated(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) { //Calling actions expected before first draw starts if (FirstDraw) { BeforeFirstDraw(); } //Exception during Act is fatal. We encapsulate it as a plain text and throw it. IAct problemActor = null; try { ForEachActor <IAct> ( a => { problemActor = a; a.Act(); return(false); } ); } catch (Exception e) { Log.e(this, "Exception happened during Act on an Actor.\n" + e.ToString()); if (problemActor != null) { Log.e(this, "Problem Actor was " + problemActor.ToString()); } //sender.RunOnGameLoopThreadAsync(async() => { await Utility.GetMusic("Sounds", "alarm_to_the_extreme"); }).AsTask(); //throw new Exception("Exception happened during Act on an Actor.\n" + e.ToString(), e); } //Background draw cycle try { BackgroundImage.Draw(args.DrawingSession); } catch (Exception e) { Log.e(this, "Problem happened during Background Draw.\n" + e.ToString()); } //Actor draw cycle //No problem should happen, but this makes debugging easier, plus any error during a single frame Draw is irrelevant anyway try { //Draw all actors ForEachActor <IActor> ( a => { a.Draw(args.DrawingSession); return(false); } ); //Draw last error log DrawErrorLog(args.DrawingSession); } catch (Exception e) { Log.e(this, "Problem happened during Draw.\n" + e.ToString()); } //Draws a broadcast message, if there is any if (MessageBroadcastCounter < MessageBroadcastTime) { var format = new Microsoft.Graphics.Canvas.Text.CanvasTextFormat(); format.FontSize = 120; format.FontStyle = Windows.UI.Text.FontStyle.Oblique; format.FontFamily = "Comic Sans"; //If I ever implement multi-line messages, this calculation has to take the longest line instead of length int moveToLeft = MessageBroadcastText.Length * 5; args.DrawingSession.DrawText(MessageBroadcastText, new Vector2(500 - moveToLeft, 200), Colors.Aquamarine, format); MessageBroadcastCounter++; } //Draws current Score { var format = new Microsoft.Graphics.Canvas.Text.CanvasTextFormat(); format.FontSize = 30; format.FontFamily = "Arial"; args.DrawingSession.DrawText("Score: " + PlayerController.CacheScore(), new Vector2(15, 15), Colors.ForestGreen, format); } //Calling actions expected after first draw finishes if (FirstDraw) { FirstDraw = false; AfterFirstDraw(); } }