Jump to content
  • Advertisement
Sign in to follow this  
David Gr

[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.

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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!