debufgdsf kspdnisa

This commit is contained in:
AnloGames 2023-08-18 19:52:48 +03:00
parent b5224f10aa
commit d176dfedf3
2 changed files with 2 additions and 57 deletions

View file

@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GUI
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
{ {
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()); /*var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.DrawString( spriteBatch.DrawString(
_spriteFont, _spriteFont,
@ -52,7 +52,7 @@ namespace DangerousD.GameCore.GUI
SpriteEffects.None, SpriteEffects.None,
0 0
); );
spriteBatch.End(); spriteBatch.End();*/
} }
public void Set(string key, string value) public void Set(string key, string value)

View file

@ -44,61 +44,6 @@ namespace DangerousD.GameCore.Managers
var currentRect = currentEntity.Rectangle; var currentRect = currentEntity.Rectangle;
var newRect = currentRect; var newRect = currentRect;
#region x collision
var collidedX = false;
var tryingRectX = currentRect;
tryingRectX.Offset((int)Math.Ceiling(currentEntity.velocity.X), 0);
foreach (var mapObject in mapObjects)
{
if (
Math.Abs(mapObject.Pos.X - currentEntity.Pos.X) < 550
&& Math.Abs(mapObject.Pos.Y - currentEntity.Pos.Y) < 550
&& tryingRectX.Intersects(mapObject.Rectangle)
)
{
collidedX = true;
break;
}
}
if (collidedX)
{
currentEntity.velocity.X = 0;
}
else
{
newRect.X = tryingRectX.X;
}
#endregion
#region y collision
var collidedY = false;
var tryingRectY = currentRect;
tryingRectY.Offset(0, (int)Math.Ceiling(currentEntity.velocity.Y));
if (currentEntity is Player)
{
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
AppManager.Instance.DebugHUD.Set("falling", (currentEntity as Player).FallingThroughPlatform.ToString());
AppManager.Instance.DebugHUD.Set("intersects y", "");
}
foreach (var mapObject in mapObjects)
{
if (tryingRectY.Intersects(mapObject.Rectangle))
{
if (currentEntity is Player) AppManager.Instance.DebugHUD.Set("intersects y", mapObject.GetType().ToString());
collidedY = true;
break;
}
}
currentEntity.isOnGround = collidedY && currentEntity.velocity.Y > 0;
if (collidedY)
{
currentEntity.velocity.Y = 0;
}
else
{
newRect.Y = tryingRectY.Y;
}
#endregion
currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y)); currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y));
} }