Hello, I am currently trying to create my first Monogame game and I have a bit of a trouble.
I am using color based collision since I have some irregular objects and it works perfectly. However one thing that I can’t figure out how to do is, how to change parts of the loaded map.png?
When I get a collision I want to make a small circle around the origin of the collision.
(Don’t pay attention to the formula I am still testing and I havent bothered to complete it)
if (this.CollisionMapData[index] == Color.ForestGreen)
{
for (double i = 0; i < 628; i++)
{
newIndex = ((int)Math.Sin(i / 100) * this.CollisionMap.Width + (int)Math.Cos(i / 100));
CollisionMapData[index] = Color.Black;
CollisionMapData[index + 1] = Color.Black;
CollisionMapData[index + 2] = Color.Black;
}
return true;
}
CollisionMapData is a 1D Color array, Color[]. I see why this approach is not working I am just storing the updated data in the array but I am not applying it to my loaded map. How do I do that?
In my LoadContent() I am loading my map like this:
this.map = new Map(new Vector2(0, 0), this.Content.Load<Texture2D>("firstMap"));
P.S. I am using this: http://stackoverflow.com/questions/14894796/per-pixel-collision-could-do-with-some-general-tips (the best answer) method to do the collision check.