private void mapCollision()
{
Rectangle correctedBox = new Rectangle(spear.Location, spear.Size);
correctedBox.X -= 27;
Vector2[] verts = VectorMath.rectVerts(correctedBox, orientation);
HashSet<int> xVals = new HashSet<int>();
HashSet<int> yVals = new HashSet<int>();
//gather values the spear might be passing through
foreach(Vector2 vertex in verts)
{
xVals.Add((int)Math.Floor(vertex.X));
yVals.Add((int)Math.Floor(vertex.Y));
}
//Using the dot product, find collidable rectangles and test.
bool colliding = false;
foreach(int x in xVals)
{
foreach(int y in yVals)
{
int squareData = m.blockInfo(new Vector2(x, y));
if(thrownBy == null && squareData >= 10)
{
Rectangle r = new Rectangle(x, y, 32, 32);
if (VectorMath.rectCollision(correctedBox, orientation, r, 0))
{
velocity.X = 0;
velocity.Y = 0;
atRest = true;
throwing = false;
Hit_Wall_Sound.Play();
colliding = true;
break;
if(bomb)
{
bombExplosion();
bomb = false;
}
}
}//This is messy, I know.
else if((squareData >= 10 && !thrownBy.blinked) || (squareData >= 10 && squareData < 20 && thrownBy.blinked))
{
Rectangle r = new Rectangle(x, y, 32, 32);
if (VectorMath.rectCollision(correctedBox, orientation, r, 0))
{
velocity.X = 0;
velocity.Y = 0;
atRest = true;
throwing = false;
Hit_Wall_Sound.Play();
colliding = true;
break;
}