# [SDL.NET - C#] Using a tileset

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

## 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 on other sites
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?

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633384
• Total Posts
3011598
• ### Who's Online (See full list)

There are no registered users currently online

×