protected override void Draw(GameTime gameTime) { base.Draw(gameTime); var camera = CurrentScene.Camera; var viewMatrix = GetViewMatrix(camera); VisibleAreaBox = GetVisibleAreaBox(viewMatrix); GraphicsDevice.SetRenderTarget(_renderTarget); _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, viewMatrix); GraphicsDevice.Clear(CurrentScene.BackgroundColor); CurrentScene.Render(_spriteBatch); #if DEBUG if (Input.ActionPressed("ShowPhysics")) { RenderPhysicsDebug(_spriteBatch); } #endif _spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp); _spriteBatch.Draw(_renderTarget, new Rectangle( _graphics.PreferredBackBufferWidth / 2 - (blitWidth / 2), _graphics.PreferredBackBufferHeight / 2 - (blitHeight / 2), blitWidth, blitHeight), Color.White); _spriteBatch.End(); }
public override void Update(float delta) { base.Update(delta); var sixtyDelta = delta * 60; //Area.AngleOffset += MathHelper.Pi / 160; if (!OnFloor) { Velocity.Y += Gravity; } if (Input.ActionPressed("move_left")) { Velocity.X -= Speed; Sprite.FlipX = true; } else if (Input.ActionPressed("move_right")) { Velocity.X += Speed; Sprite.FlipX = false; } else { Velocity.X -= Decel * Math.Sign(Velocity.X); if (Math.Abs(Velocity.X) <= Decel) { Velocity.X = 0; } } if (Input.ActionJustPressed("fire")) { Velocity.Y = -JumpHeight; } else if (Input.ActionJustReleased("fire") && Velocity.Y < 0) { Velocity.Y *= 0.5f; } }