Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL + Tiles some problems

Started by JonasKnapp Sep 7, 2011 at 11:22 AM 1 replies 1.3k views
Original Post
JonasKnapp
JonasKnapp
Hi,
i wrote some code for a tile based game, but the tiles aren't working correctly.
I tried solving this problem for the last days, but i didn't find a saluting, i hope you can.

The problems are:
1. The result of the tile placing is very strange, but i can't find any problems with the code of it.
2. This is not so important, but it would be good to know, why the color keying doesn't work, maybe the picture doesn't work with colorkeying or the code itself is wrong. I don't know.

Some notes:
1. I commented the code a lot for you, so you can understand it.
2. You will need SDL + SDL_image to compile it, because it like it to have png files as images.
3. I don't know why i should write it here, but maybe it helps to know that my operating system is OS X LION.
4. I'm a beginner in programming SDL and this is my first game i want to program.
5. I'm from germany (this includes a sorry for mistakes, if you find any in the text), if you can speak german too i think it's better to write in german for me.
6. I wrote my email at the top of the main.cpp if you want to contact me without gamedev.net.

The code (main.cpp) + the tile sheet (everything made by me) + the background (a white background =D):
It should be downloadable down here(, if it worked xD):
[s]----[/s]> [attachment=5285:tilesheet + background + maincpp.zip]

And now its time to thank you for hopefully good answers.
Wooh
Wooh

1. The result of the tile placing is very strange, but i can't find any problems with the code of it.
You mean why some tiles are white? It is because you never set the alive value on the tiles.

2. This is not so important, but it would be good to know, why the color keying doesn't work, maybe the picture doesn't work with colorkeying or the code itself is wrong. I don't know.
The colorkey is working. If you remove the colorkey code you will have a box moving around. Note that colorkey only makes one color transparent so different shades will not be handled as a colorkey color. That's why you have some shades of magenta visible in around the arrow.
JonasKnapp
JonasKnapp
Thank you, you solved my problem!
You must i know i changed my Tile-Drawing code a lot and completely forget to set the alive bool to true.
I think the colorkeying problem just happens on my computer maybe because of the new Lion os.
On my Pc the player is a box with an arrow and not just a Black arrow with some magneta, but your info that it worked on your pc helped me.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.