protected override void Draw(GameTime gameTime) { //gameTime = new GameTime(gameTime.TotalGameTime / 5, gameTime.ElapsedGameTime / 5); SceneManager.Draw(spriteBatch); #if DEBUG var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; lastPrint += gameTime.ElapsedGameTime.Milliseconds; frameCounter.Update(deltaTime); if (lastPrint > 10) { fps = string.Format("FPS: {0}", (int)frameCounter.AverageFramesPerSecond); lastPrint = 0; } spriteBatch.Begin(); spriteBatch.DrawString(font, fps, new Vector2(1, 1), Color.Red); spriteBatch.End(); #endif // TODO: Add your drawing code here 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) { /* * var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; * * _frameCounter.Update(deltaTime); * * var fps = string.Format("FPS: {0}", _frameCounter.AverageFramesPerSecond); * * * Graphics.GraphicsDevice.Clear (Color.CornflowerBlue); * * //TODO: Add your drawing code here * spriteBatch.Begin(); * foreach (Bunny bunny in bunnies) { * spriteBatch.Draw (image, new Vector2(bunny.posX, bunny.posY)); * } * spriteBatch.DrawString(font, fps, new Vector2(1, 1), Color.Black); * spriteBatch.DrawString(font, ""+bunniesCount, new Vector2(this.GraphicsDevice.Viewport.Width-100, 1), Color.Blue); * spriteBatch.End ();*/ base.Draw(gameTime); var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); var fps = string.Format("FPS: {0}", _frameCounter.AverageFramesPerSecond); spriteBatch.Begin(); spriteBatch.DrawString(font, fps, new Vector2(1, 1), Color.White); spriteBatch.DrawString(font, "" + bunniesCount, new Vector2(this.GraphicsDevice.Viewport.Width - 100, 1), Color.White); spriteBatch.End(); }
protected override void Update(GameTime gameTime) { FrameCounter.Update(gameTime); float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; TaskManager.Update(dt); Input.Update(dt); Client.Update(dt); if (Client.IsConnected) { UpdateGame(dt); } else if (Client.IsConnecting) { UpdateConnecting(dt); } else { UpdateUnconnected(dt); } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Client.Disconnect(); Exit(); } base.Update(gameTime); }
public override int Update() { framecount.Update(); Move(); return((int)(framecount.IsCall ? GENERICATTACKSTATENAME.Homing : GENERICATTACKSTATENAME.Changeless)); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); this.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; foreach (BasicDraw basicDraw in basicDrawList) { basicDraw.Draw(gameTime); } if (showStats) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; frameCounter.Update(deltaTime); var fps = string.Format("FPS: {0}", frameCounter.AverageFramesPerSecond); var pos = string.Format("Player position: {0}", Camera.getCameraPosition()); spriteBatch.Begin(); spriteBatch.DrawString(font, fps, new Vector2(1, 1), Color.Black); spriteBatch.DrawString(font, pos, new Vector2(1, 20), Color.Black); 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.Clear(Color.Teal); spriteBatch.Begin(); gameState.Draw(spriteBatch); #region Drawing Cursor spriteBatch.Draw(CustomCursor, new Vector2(Mouse.GetState().X - CustomCursor.Width / 2, Mouse.GetState().Y - CustomCursor.Height / 2)); #endregion #region Drawing fps var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; frameCounter.Update(deltaTime); var fps = string.Format("FPS: {0}", frameCounter.AverageFPS); spriteBatch.DrawString(font, fps, new Vector2(WindowWidth - 150, 1), Color.Red, 0f, new Vector2(0, 0), 0.2f, SpriteEffects.None, 1f); #endregion #region Drawing IP Adress spriteBatch.DrawString(font, "IP : " + ip, new Vector2(WindowWidth - 150, 33), Color.Red, 0f, new Vector2(0, 0), 0.2f, SpriteEffects.None, 1f); #endregion spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Called when the DrawableGameComponent needs to be drawn. Override this method with /// component-specific drawing code. /// </summary> /// <param name="gameTime">Time passed since the last call to Draw.</param> public virtual void Draw(TickCount gameTime) { // Update the FPS _fps.Update(gameTime); // Clear the screen _game.RenderWindow.Clear(DrawingManager.BackgroundColor); // Draw the active non-console screen var ancs = ActiveNonConsoleScreen; if (ancs != null) { ancs.Draw(gameTime); } // Draw the console var cs = ConsoleScreen; if (ShowConsole && cs != null) { cs.Draw(gameTime); } // Draw the console if (ShowConsole && ConsoleScreen != null) { ConsoleScreen.Draw(gameTime); } }
private void CountFps() { var deltaTime = (float)_sWatch.Elapsed.TotalSeconds; _sWatch = Stopwatch.StartNew(); _frameCounter.Update(deltaTime); }
/// <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) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); if (timer > TimeSpan.Zero) { timer -= gameTime.ElapsedGameTime; if (timer <= TimeSpan.Zero) { fps = string.Format("FPS: {0}", _frameCounter.AverageFramesPerSecond); timer = TimeSpan.FromSeconds(.5); } } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here var kstate = Keyboard.GetState(); if (kstate.IsKeyDown(Keys.Up)) { ballPosition.Y -= ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (kstate.IsKeyDown(Keys.Down)) { ballPosition.Y += ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (kstate.IsKeyDown(Keys.Left)) { ballPosition.X -= ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } if (kstate.IsKeyDown(Keys.Right)) { ballPosition.X += ballSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } ballPosition.X = Math.Min(Math.Max(ballTexture.Width / 2, ballPosition.X), graphics.PreferredBackBufferWidth - ballTexture.Width / 2); ballPosition.Y = Math.Min(Math.Max(ballTexture.Height / 2, ballPosition.Y), graphics.PreferredBackBufferHeight - ballTexture.Height / 2); animatedSprite.Update(); angle += 0.01f; blueAngle += blueSpeed; greenAngle += greenSpeed; redAngle += redSpeed; base.Update(gameTime); }
private string getFps(GameTime gameTime) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; frameCounter.Update(deltaTime); var fps = string.Format("FPS: {0}", (int)frameCounter.AverageFramesPerSecond); return(fps); }
public override void Draw(GameTime gameTime, SpriteBatch graphics) { float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); graphics.DrawString(Font, FPS, Vector2.Zero, Color.Black); graphics.DrawString(Font, MousePos, new Vector2(0, 13), Color.Black); graphics.DrawString(Font, KeysPressed, new Vector2(0, 25), Color.Black); }
public override int Update() { frame.Update(); if (frame.IsCall) { parent.ChangeState(SUBSTATENAME.Shot); } return((int)SUBSTATENAME.Changeless); }
/// <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) { _frameCounter.Update((float)gameTime.ElapsedGameTime.TotalSeconds); graphics.GraphicsDevice.Clear(_screen.BackgroundColor); _screen.Draw(spriteBatch); Systems.Draw(spriteBatch, _entities); _screen.DrawAfterEntities(spriteBatch); base.Draw(gameTime); }
public virtual void DrawFPSCounter(GameTime gameTime) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); var fps = string.Format("FPS: {0}", (int)System.Math.Ceiling(_frameCounter.AverageFramesPerSecond)); spriteBatch.Begin(); spriteBatch.DrawString(font, fps, new Vector2(1, 1), Color.Green); spriteBatch.End(); }
public int Update() { frame.Update(); if (frame.IsCall) { parent.BackSelectScene(); } return((int)STATENAME.Changeless); }
/// <summary> /// Draws the HUD. /// </summary> /// <param name="GameTime"></param> public void Draw(GameTime GameTime) { HudView.Draw(GameTime.ElapsedGameTime.TotalMilliseconds); HudRenderTarget.Begin(); FramerateCounter.Update((float)GameTime.ElapsedGameTime.TotalSeconds); DrawDebugInfo(); HudRenderTarget.End(); }
public int Update() { frame.Update(); if (frame.IsCall) { parent.Retry(); } return((int)STATENAME.Changeless); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; frameCounter.Update(deltaTime); graphicsDevice.Clear(Color.CornflowerBlue); /* * Background */ spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp); spriteBatch.Draw(backgroundGradientStrip, new Rectangle(0, 0, Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight), Color.White); spriteBatch.End(); /* * World Render */ spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: camera.Transform); level.Draw(gameTime, spriteBatch); foreach (Sprite s in enemies) { s.Draw(gameTime, spriteBatch); } foreach (Sprite s in pufferFish) { s.Draw(gameTime, spriteBatch); } player.Draw(gameTime, spriteBatch); //DrawBodyShape(player, spriteBatch, new Color(0, 150, 0, 150)); //DrawBodyShape(player, spriteBatch, new Color(0, 160, 0, 170)); //DrawBodyShape(spikesPointingDown[0], spriteBatch, new Color(160, 0, 0, 170)); //DrawBodyShape(spikesPointingUp[0], spriteBatch, new Color(160, 0, 0, 170)); spriteBatch.End(); /* * GUI render */ spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp); energyBar.Draw(spriteBatch, gameTime); healthBar.Draw(spriteBatch, gameTime); //spriteBatch.DrawString(font, $"{(int)camera.Position.X}, {(int)camera.Position.Y}, {camera.Zoom}", new Vector2(0, graphicsDevice.Viewport.Height - 16), Color.Red); spriteBatch.DrawString(font, player.Body.GetDebugString(), new Vector2(0, 48), Color.Red); spriteBatch.DrawString(font, $"{Math.Round(frameCounter.AverageFramesPerSecond)}", Vector2.Zero, Color.LightGreen); spriteBatch.End(); }
/// <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) { frameCounter.Update((float)gameTime.ElapsedGameTime.TotalMilliseconds); handelInput(); foreach (Entity entity in entities) { entity.onTick(map); } base.Update(gameTime); }
public void Draw(GameTime gametime, Color tint) { _frameCounter.Update((float)gametime.ElapsedGameTime.TotalSeconds); Engine.BeginRender(_scene); _scene.RenderScene(gametime); _fps.Text = "FPS - " + Math.Round(_frameCounter.AverageFramesPerSecond); Engine.EndRender(); }
public override int Update() { frame.Update(); shotInterval.Update(); if (shotInterval.IsCall) { parent.CreateBullet(); } return((int)(frame.IsCall ? SUBSTATENAME.Shot : SUBSTATENAME.Changeless)); }
public void Update(float deltaTime) { _frameCounter.Update(deltaTime); InputManager.Update(deltaTime); UpdateTime(deltaTime); if (_paused) { return; } World.Update(deltaTime); }
private void Update() { if (!frameCounter.Update()) { return; } if (!searching) // Avoid value change during search (This may cause problems). { DrawersUpdateOnUpdate(); } Repaint(); }
/// <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) { GraphicsDevice.Clear(Color.CornflowerBlue); var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); Universal.SpriteBatch.Begin(); base.Draw(gameTime); ScreenManager.Draw(); Universal.SpriteBatch.DrawString(Fonts.Arial_12, fps, new Vector2(25, 25), Color.White); Universal.SpriteBatch.End(); }
public override void Draw(GameTime gameTime) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _frameCounter.Update(deltaTime); var fps = $"FPS: {_frameCounter.AverageFramesPerSecond:.00}"; var playerPos = PositionHelper.GetSectorAsVector(Player.Body.Position); DrawBackground(); DrawWorldObjects(gameTime); DrawOverlays(fps, playerPos); base.Draw(gameTime); }
public void Update() { counter.Update(); if (blinkTime <= 0) { targetSprite.enabled = true; flag = false; return; } //3フレームに一回消える targetSprite.enabled = !counter.IsCall; blinkTime--; }
public void Draw(GameTime gametime, Color tint) { _frameCounter.Update((float)gametime.ElapsedGameTime.TotalSeconds); Engine.BeginRender(_scene); _titles.Text = "Duck Attack"; _titles.Location = new Vector2(150, 200); _scene.RenderScene(gametime); Engine.EndRender(); }
/// <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(); } InputManager.Update(gameTime); gameWorld.Update(gameTime, camera); camera.PointTo(gameWorld.player); frameCounter.Update(gameTime); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { Stopwatch sw = new Stopwatch(); sw.Start(); FrameCounter.Update(gameTime); DebugConsole.Reset(); DebugKeyPress(); if (GSS.Controlls.Start()) { Exit(); } switch (GSS.RenderState) { case RenderState.Intro: GSS.Intro.Update(); break; case RenderState.MainMenu: GSS.MainMenu.Update(); break; case RenderState.IngameMenu: GSS.IngameMenu.Update(); break; case RenderState.World: GSS.World.Update(gameTime); break; case RenderState.Scene: GSS.ActiveScene.Update(gameTime); break; case RenderState.Battle: GSS.Battle.Update(gameTime); break; case RenderState.Area: break; } base.Update(gameTime); DebugConsole.WriteLine($"Update {GSS.RenderState}: {sw.ElapsedMilliseconds}ms"); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.Clear(ClearBufferMask.ColorBufferBit); using (var dc = new DrawingContext(this, SpriteBatch)) { currentScreen.Draw(dc); } SwapBuffers(); #if DEBUG frameCounter.Update(); Title = $"{WindowTitle} [FPS: {frameCounter.FramesPerSecond}] [Render Calls: {SpriteBatch.RenderCount}]"; SpriteBatch.RenderCount = 0; #endif }