Page 2 of 2

Re: Deleting surfaces in SDL

Posted: Wed Jan 14, 2009 3:47 pm
by Vortex
Yes i have changed the color already to the background color this solution works fine now, im just curious on how to handle this when you got ( i uses this for an exampel now ) diffrent tiles that is beneath the button and when your hiding the button and covering it with a sdl rect like you just did then it whould cover the tiles and it whould look weird, or maybe im thinking wrong :P

anyway thanks alot for your patience and help :bow:

Re: Deleting surfaces in SDL

Posted: Wed Jan 14, 2009 4:05 pm
by programmerinprogress
Well, the order things are drawn depends on the way you program them, in the example I showed you there, I placed the FillRect function before everything else was drawn, and then all of the object are drawn to the screen in the order you tell the program to draw them.

You can also come up with a system that implements a thing called a Z-order in your programs, basically you assign your objects different priorities(or Z-Orders) for drawing, to create the effect of foreground and background, or to prevent buttons from being overlapped by sprites.

This will probably be the priority for a program you write:
Top Layer = your buttons and your counters/text
Middle Layer = your sprites and moving objects
Bottom Layer = your background

You could also use some foreground, and make a separate level for panels(which would be under your buttons and text, but over your sprites)

You don't have to create anything extra (although this helps organise things), you could just draw everything in that order.


PS: also you're not covering anything, you're just clearing the surface and redrawing the images.

Re: Deleting surfaces in SDL

Posted: Thu Jan 15, 2009 8:15 am
by Vortex
ahh ok, ill look more into Z-order once i get more a hang of SDL maybe after lazyfoo´s tutorials.

once again thank you for taking time to anwser and help me :)