minor changes and fixes, waiting for physics fix
This commit is contained in:
parent
a3b2fb2b81
commit
5a5a24dffd
3 changed files with 42 additions and 34 deletions
|
@ -48,9 +48,12 @@ namespace DangerousD.GameCore
|
|||
GraphicsComponent.Update();
|
||||
}
|
||||
|
||||
//static Texture2D debugTexture;
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
||||
//debug
|
||||
//spriteBatch.Draw(debugTexture, Rectangle, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,6 +53,7 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
//GameObject.te
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
|
|
|
@ -20,12 +20,6 @@ namespace DangerousD.GameCore.Managers
|
|||
item.velocity = item.velocity + item.acceleration * delta;
|
||||
}
|
||||
|
||||
//SD setting positions before check
|
||||
foreach (var item in livingEntities)
|
||||
{
|
||||
item.SetPosition(item.Pos + item.velocity);
|
||||
}
|
||||
|
||||
CheckCollisions(livingEntities, mapObjects);
|
||||
OnCollision(entities, livingEntities);
|
||||
OnCollision(livingEntities);
|
||||
|
@ -44,39 +38,49 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
for (int i = 0; i < livingEntities.Count; i++)
|
||||
{
|
||||
Rectangle oldRect = new Rectangle();
|
||||
var currentEntity = livingEntities[i];
|
||||
Rectangle oldRect = currentEntity.Rectangle;
|
||||
|
||||
|
||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (livingEntities[i].Rectangle.Intersects(mapObjects[j].Rectangle))
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
if (livingEntities[i].Rectangle.Right > mapObjects[j].Rectangle.Left)
|
||||
{
|
||||
|
||||
//livingEntities[i].SetPosition(livingEntities[i].Pos- new Vector2(livingEntities[i].velocity.X));
|
||||
livingEntities[i].velocity.X = 0;
|
||||
livingEntities[i].SetPosition(new Vector2(livingEntities[i].Pos.X - (livingEntities[i].Rectangle.Right - mapObjects[j].Rectangle.Left),
|
||||
livingEntities[i].Pos.Y));
|
||||
}
|
||||
if (livingEntities[i].Rectangle.Left < mapObjects[j].Rectangle.Right)
|
||||
{
|
||||
livingEntities[i].velocity.X = 0;
|
||||
livingEntities[i].SetPosition(new Vector2(livingEntities[i].Pos.X + mapObjects[j].Rectangle.Right - livingEntities[i].Rectangle.Left,
|
||||
livingEntities[i].Pos.Y));
|
||||
}
|
||||
if (livingEntities[i].Rectangle.Bottom > mapObjects[j].Rectangle.Top)
|
||||
{
|
||||
livingEntities[i].velocity.Y = 0;
|
||||
livingEntities[i].SetPosition(new Vector2(livingEntities[i].Pos.X,
|
||||
livingEntities[i].Pos.Y - (livingEntities[i].Rectangle.Bottom - mapObjects[j].Rectangle.Top)));
|
||||
}
|
||||
if (livingEntities[i].Rectangle.Top > mapObjects[j].Rectangle.Bottom)
|
||||
{
|
||||
livingEntities[i].velocity.Y = 0;
|
||||
livingEntities[i].SetPosition(new Vector2(livingEntities[i].Pos.X,
|
||||
livingEntities[i].Pos.Y + (mapObjects[j].Rectangle.Bottom - livingEntities[i].Rectangle.Top)));
|
||||
}
|
||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
oldRect.Offset(0, (int)currentEntity.velocity.Y/2);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
oldRect.Offset(0, (int)currentEntity.velocity.Y / 2);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue