I’m trying to make a simple game for a school project in python using a tile map and the module pytmx. The problem is that when I load the map, my tiles are correctly drawn but the background (which might be transparent according to the editor) is totally black.
(A screenshot from the game)
(A screenshot from the editor)
I hope someone could tell me what I did wrong ^^’
Thanks you
What do you expect “transparent” to look like in your game?
Generally speaking, program windows are opaque, and have some default fill colour (usually black). So, what you’re seeing is that default fill colour and then your correctly rendered transparency on top of that.
If you want something other than black, then you’ll need to render something there, such as a background colour or more background layers, or some texture.
If you want the window itself to be transparent (i.e., for the desktop to show through), you’ll need to do OS-specific trickery to create that, which involves specifically telling the OS which parts of your window should be transparent. And even that will still give you a black background if the game is running in exclusive fullscreen, I think.
Thanks for replying ^^,
In fact I was expecting the background to be transparent and to be showing the layer below in the editor. I tried to place an image above the others layers and then below. I ran the game with those two configurations and the image was correctly drawn on the screen when it was above, but was hidden by the OS default’s color.
Oh, so there’s stuff being obscured in the render view? Since your screenshots are of two different areas, I didn’t see.
In that case, you’re probably either not parsing the tileset images’ alpha channel when you load them, or you’re not using alpha blending when you render them. I’m not familiar with how to check/set these things in Pygame, but hopefully this will help narrow down your documentation search :]
By the way, in this case, your map background colour is irrelevant, since the issue is apparently with layers, not your map as a whole. Your emphasis on the background colour probably contributed to me misunderstanding your issue :'D I thought you were talking about your map “missing” transparency, but you were talking about layers.
Yeah I think the alpha channel is a good way to start investigations =D. I tried to decrease the alpha value looking for some changes and, yeah, nothing changed.
If I found something interesting I will post it here, thanks for your help and time ^^