bound camera y-position by world & change dynamics slightly
This commit is contained in:
parent
10c2a86feb
commit
fccca0c676
@ -21,22 +21,31 @@ namespace SemiColinGames {
|
||||
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height + Top, Top, -1, 1);
|
||||
}
|
||||
|
||||
public void Update(float modelTime, Player player, int worldWidth) {
|
||||
public void Update(float modelTime, Player player, int worldWidth, int worldHeight) {
|
||||
Vector2 pos = player.Position;
|
||||
float xDiff = pos.X - bbox.Center.X;
|
||||
float yDiff = pos.Y - bbox.Center.Y;
|
||||
if (Math.Abs(xDiff) > 16) {
|
||||
bbox.Offset((int) (xDiff * 0.1), 0);
|
||||
}
|
||||
if (Math.Abs(yDiff) > 16 && player.StandingOnGround) {
|
||||
if (player.StandingOnGround) {
|
||||
bbox.Offset(0, (int) (yDiff * 0.1));
|
||||
}
|
||||
if (yDiff > 16) {
|
||||
bbox.Offset(0, (int) (yDiff * 0.2));
|
||||
}
|
||||
if (bbox.Left < 0) {
|
||||
bbox.Offset(-bbox.Left, 0);
|
||||
}
|
||||
if (bbox.Right > worldWidth) {
|
||||
bbox.Offset(worldWidth - bbox.Right, 0);
|
||||
}
|
||||
if (bbox.Top < 0) {
|
||||
bbox.Offset(0, -bbox.Top);
|
||||
}
|
||||
if (bbox.Bottom > worldHeight) {
|
||||
bbox.Offset(0, worldHeight - bbox.Bottom);
|
||||
}
|
||||
if (shakeTime > 0) {
|
||||
shakeTime -= modelTime;
|
||||
int x = random.Next(-4, 5);
|
||||
|
@ -162,7 +162,7 @@ namespace SemiColinGames {
|
||||
Reset();
|
||||
}
|
||||
LinesOfSight.Update(npcs, CollisionTargets);
|
||||
Camera.Update(modelTime, Player, Width);
|
||||
Camera.Update(modelTime, Player, Width, Height);
|
||||
}
|
||||
|
||||
public void ScreenShake() {
|
||||
|
Loading…
Reference in New Issue
Block a user