Compare commits
No commits in common. "10c2a86febea8fd07b4702cd0815af75e73eb9be" and "3be37740f7dbf3c58f1c1ec0c811ea200cd996ce" have entirely different histories.
10c2a86feb
...
3be37740f7
@ -18,18 +18,13 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
|
|
||||||
public Matrix Projection {
|
public Matrix Projection {
|
||||||
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height + Top, Top, -1, 1);
|
get => Matrix.CreateOrthographicOffCenter(Left, Left + Width, Height, 0, -1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(float modelTime, Player player, int worldWidth) {
|
public void Update(float modelTime, Vector2 player, int worldWidth) {
|
||||||
Vector2 pos = player.Position;
|
float diff = player.X - bbox.Center.X;
|
||||||
float xDiff = pos.X - bbox.Center.X;
|
if (Math.Abs(diff) > 16) {
|
||||||
float yDiff = pos.Y - bbox.Center.Y;
|
bbox.Offset((int) (diff * 0.1), 0);
|
||||||
if (Math.Abs(xDiff) > 16) {
|
|
||||||
bbox.Offset((int) (xDiff * 0.1), 0);
|
|
||||||
}
|
|
||||||
if (Math.Abs(yDiff) > 16 && player.StandingOnGround) {
|
|
||||||
bbox.Offset(0, (int) (yDiff * 0.1));
|
|
||||||
}
|
}
|
||||||
if (bbox.Left < 0) {
|
if (bbox.Left < 0) {
|
||||||
bbox.Offset(-bbox.Left, 0);
|
bbox.Offset(-bbox.Left, 0);
|
||||||
@ -40,14 +35,13 @@ namespace SemiColinGames {
|
|||||||
if (shakeTime > 0) {
|
if (shakeTime > 0) {
|
||||||
shakeTime -= modelTime;
|
shakeTime -= modelTime;
|
||||||
int x = random.Next(-4, 5);
|
int x = random.Next(-4, 5);
|
||||||
int y = random.Next(-4, 5);
|
bbox.Offset(x, 0);
|
||||||
bbox.Offset(x, y);
|
|
||||||
}
|
}
|
||||||
Debug.AddToast($"p: {pos.X}, {pos.Y} c: {bbox.Center.X}");
|
Debug.AddToast($"p: {player.X}, {player.Y} c: {bbox.Center.X}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Shake() {
|
public void Shake() {
|
||||||
shakeTime = 0.3f;
|
shakeTime = 0.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,8 @@ namespace SemiColinGames {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
Facing = facing;
|
Facing = facing;
|
||||||
Health = MaxHealth;
|
Health = MaxHealth;
|
||||||
StandingOnGround = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StandingOnGround { get; private set; }
|
|
||||||
|
|
||||||
public int MaxHealth { get; private set; } = 3;
|
public int MaxHealth { get; private set; } = 3;
|
||||||
|
|
||||||
public int Health { get; private set; }
|
public int Health { get; private set; }
|
||||||
@ -132,12 +129,12 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StandingOnGround = false;
|
bool standingOnGround = false;
|
||||||
AABB groundIntersect = BoxOffset(position, 1);
|
AABB groundIntersect = BoxOffset(position, 1);
|
||||||
foreach (var box in candidates) {
|
foreach (var box in candidates) {
|
||||||
if (groundIntersect.Intersect(box) != null) {
|
if (groundIntersect.Intersect(box) != null) {
|
||||||
Debug.AddRect(box, Color.Cyan);
|
Debug.AddRect(box, Color.Cyan);
|
||||||
StandingOnGround = true;
|
standingOnGround = true;
|
||||||
if (box.Tile?.IsHazard ?? false) {
|
if (box.Tile?.IsHazard ?? false) {
|
||||||
Debug.AddRect(box, Color.Red);
|
Debug.AddRect(box, Color.Red);
|
||||||
harmedByCollision = true;
|
harmedByCollision = true;
|
||||||
@ -145,7 +142,7 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StandingOnGround) {
|
if (standingOnGround) {
|
||||||
jumps = 1;
|
jumps = 1;
|
||||||
ySpeed = -0.0001f;
|
ySpeed = -0.0001f;
|
||||||
Debug.AddRect(Box(position), Color.Cyan);
|
Debug.AddRect(Box(position), Color.Cyan);
|
||||||
|
@ -162,7 +162,7 @@ namespace SemiColinGames {
|
|||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
LinesOfSight.Update(npcs, CollisionTargets);
|
LinesOfSight.Update(npcs, CollisionTargets);
|
||||||
Camera.Update(modelTime, Player, Width);
|
Camera.Update(modelTime, Player.Position, Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScreenShake() {
|
public void ScreenShake() {
|
||||||
|
Loading…
Reference in New Issue
Block a user