Dear experts I am trying to create a bomberman type game and have done bits of it such as back ground using a tile engine and anmating sprites on the move. I have come across a problem when tring to make a block immpassible (like the bomberman grid ever 2 sprites should be a block which is none destructive). I can do the first tile as shown later but not the others, Below is my code snipet:
protected bool Collide()
{
int skullCollisionRectOffset = 0;
int tileRectOffset = 5;
Rectangle blockRect = new Rectangle( // Creates Rectangle around impassible block
tileWidth * 2, // reason i have *2 is because the first impassible tile is double the hieght and width from top left of screen lol...
tileHeight * 2, // this will only make the first block immpassible
tileWidth,
tileHeight);
Rectangle skullRect = new Rectangle( // Creates Rectangle around character
(int)skullPosition.X + skullCollisionRectOffset,
(int)skullPosition.Y + skullCollisionRectOffset,
skullFrameSize.X - (skullCollisionRectOffset *2),
skullFrameSize.Y - (skullCollisionRectOffset *2));
return blockRect.Intersects(skullRect);
}
I have come up with a few ideas none of which i can get to work... first idea is because im using a list to create my tiles and using a nested for loop to draw them something like:
int[,] map = {
{4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5,}, // the numbers in this list refur to a tile sprite
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{10, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2,},
{10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,},
{6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7,},
is there a way i can say something like:
if(map.value = 3) // where 3 is the impassive tile (not sure if .value is how you check for a certain number in the list?)
{
++x; // Increment x every time this is called
Rectangle blockRect[x] = new Rectangle( // make an array to store the rectangles? although xna isnt happy with this
tileWidth,
tileHeight,
tileWidth,
tileHeight);
}
basically this is an idea but I really havnt a clue what to do lol.. sorry for being a n00b at this but im learning...
Thanks in advance!