• Advertisement
Sign in to follow this  

[SDL.NET - C#] Using a tileset

This topic is 2953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, for a game i am making i need to use a tileset for maps etc. The code i have using to do this is:
Surface[,] Map = new Surface[12, 7];
Surface Tileset = new Surface("Content/Tileset.png");

for (int x = 0; x < 12; x++)
{
    for (int y = 0; y < 7; y++)
    {
        Map[x, y] = Tileset.CreateSurfaceFromClipRectangle(new Rectangle((x*16)+(x+1), (y*16)+(y+1), 16, 16));
        Map[x, y].Convert(Tileset);
    }
}



Each tile on the tileset in a 16x16 square and there is a 1 pixel gap between each one. I thought this code would work but when i blit the created surface it is just a plain black 16x16 square. I have tried it with and with the .Convert(Tileset) but no success :( One more thing i tried was using the SaveBmp() to see if it was the blitting or just the surface creation, and this showed that it was infact the creation. And finally, i tried blitting the initial tileset surface to see if that was also plain black, but it loaded perfectly :( I have no idea what else i can try to fix this. Anyone know what has happened here? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Hi!

i have the same problem.. it seems like alpha will be wrong calculated.
If you use a bitmap instead of a png everything works fine.

May be theres another solution to create the picture from a png-tileset?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement