diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 0122b50..04eec1b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -47,5 +47,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { velocity.Y = -300; } + public override void Update(GameTime gameTime) + { + GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint(); + velocity.X = 0.5f; + base.Update(gameTime); + } } } diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index beb6928..32851e2 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -164,8 +164,9 @@ namespace DangerousD.GameCore.Graphics scale = destinationRectangle.Width / sourceRectangle.Width; destinationRectangle.Height = (int)(sourceRectangle.Height * scale); } - - + + destinationRectangle.X -= CameraPosition.X; + destinationRectangle.Y -= CameraPosition.Y; _spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White); } @@ -187,6 +188,8 @@ namespace DangerousD.GameCore.Graphics destinationRectangle.Height = (int)(sourceRectangle.Height * scale); } + destinationRectangle.X -= CameraPosition.X; + destinationRectangle.Y -= CameraPosition.Y; _spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White); @@ -215,5 +218,6 @@ namespace DangerousD.GameCore.Graphics interval = lastInterval; } } + public static Point CameraPosition = new Point(0, 0); } }