Colin McMillen
4 years ago
5 changed files with 78 additions and 38 deletions
-
24Jumpy.Shared/Camera.cs
-
17Jumpy.Shared/Debug.cs
-
23Jumpy.Shared/JumpyGame.cs
-
11Jumpy.Shared/Player.cs
-
41Jumpy.Shared/World.cs
@ -1,10 +1,24 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
|
using Microsoft.Xna.Framework; |
||||
|
using System; |
||||
|
|
||||
namespace Jumpy { |
namespace Jumpy { |
||||
class Camera { |
class Camera { |
||||
public const int Width = 1920 / 6; |
|
||||
public const int Height = 1080 / 6; |
|
||||
|
private Rectangle bbox = new Rectangle(0, 0, 1920 / 6, 1080 / 6); |
||||
|
|
||||
|
public int Width { get => bbox.Width; } |
||||
|
public int Height { get => bbox.Height; } |
||||
|
public int Left { get => bbox.Left; } |
||||
|
|
||||
|
public void Update(GameTime time, Point player) { |
||||
|
int diff = player.X - bbox.Center.X; |
||||
|
// TODO: use the actual center of the player's bbox.
|
||||
|
if (Math.Abs(diff) > 16) { |
||||
|
bbox.Offset((int) (diff * 0.1), 0); |
||||
|
} |
||||
|
if (bbox.Left < 0) { |
||||
|
bbox.Offset(-bbox.Left, 0); |
||||
|
} |
||||
|
Debug.Toast($"p: {player.X} c: {bbox.Center.X}"); |
||||
|
} |
||||
} |
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue