Skip to content

Instantly share code, notes, and snippets.

@localdevm
Created December 22, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localdevm/28bf14ff3d15d9df0e19e31aae7417f5 to your computer and use it in GitHub Desktop.
Save localdevm/28bf14ff3d15d9df0e19e31aae7417f5 to your computer and use it in GitHub Desktop.
public void Collision(Level activelevel)
{
for (int x = 0; x < activelevel.Length; x++)
{
for (int y = 0; y < activelevel.Height; y++)
{
if (activelevel.blokTileArray[x, y] != null)
{
if (this.ColRectangle.Bottom +6> activelevel.blokTileArray[x, y].ColRectangle.Top &&
this.ColRectangle.Right - 20> activelevel.blokTileArray[x,y].ColRectangle.Left &&
this.ColRectangle.Left + 20 < activelevel.blokTileArray[x, y].ColRectangle.Right &&
this.ColRectangle.Top < activelevel.blokTileArray[x, y].ColRectangle.Bottom)
{
falling = false;
position.Y = activelevel.blokTileArray[x, y].ColRectangle.Top - 70;
}
else
{
falling = true;
}
//SHIT LIKE ME!!!
if (this.ColRectangle.Right - 20 >= activelevel.blokTileArray[x, y].ColRectangle.Left &&
this.ColRectangle.Right + 20 <= activelevel.blokTileArray[x, y].ColRectangle.Right &&
this.ColRectangle.Bottom < activelevel.blokTileArray[x,y].ColRectangle.Top &&
this.ColRectangle.Top > activelevel.blokTileArray[x,y].ColRectangle.Bottom)
{
//this.position.X -= 4;
right = false;
}
//WORKS GREAT!!!
if (this.ColRectangle.Left + 20 <= activelevel.blokTileArray[x, y].ColRectangle.Right &&
this.ColRectangle.Left - 20 >= activelevel.blokTileArray[x, y].ColRectangle.Left &&
this.ColRectangle.Bottom > activelevel.blokTileArray[x, y].ColRectangle.Top &&
this.ColRectangle.Top < activelevel.blokTileArray[x, y].ColRectangle.Bottom)
{
//this.position.X += 4;
left = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment