AddCamera
This commit is contained in:
parent
81dd082141
commit
0ff6c7ddea
2 changed files with 12 additions and 2 deletions
|
@ -47,5 +47,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
velocity.Y = -300;
|
velocity.Y = -300;
|
||||||
}
|
}
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
||||||
|
velocity.X = 0.5f;
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,9 @@ namespace DangerousD.GameCore.Graphics
|
||||||
scale = destinationRectangle.Width / sourceRectangle.Width;
|
scale = destinationRectangle.Width / sourceRectangle.Width;
|
||||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +188,8 @@ namespace DangerousD.GameCore.Graphics
|
||||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
|
@ -215,5 +218,6 @@ namespace DangerousD.GameCore.Graphics
|
||||||
interval = lastInterval;
|
interval = lastInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static Point CameraPosition = new Point(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue