GLBasic forum

Main forum => GLBasic - en => Topic started by: quick2code on 2008-Nov-20

Title: Z Order + Palette Swap
Post by: quick2code on 2008-Nov-20
One thing I haven't figured out yet is how Z-Order works with images in GlBasic. How do you put one image in front of or behind the other?

Also this may be a silly question but I was wondering if palette swapping can be done with GlBasic. This is the function in old school arcade games where sprites were different colors on different levels by loading a different palette for each. I heard this wasn't possible with 16 bit color and up but the Allegro library and SDL can do this. Thanks.
Title: Re: Z Order + Palette Swap
Post by: Moru on 2008-Nov-20
The images are drawn in the order you program does it. If you want something to be on top you draw it last.
Title: Re: Z Order + Palette Swap
Post by: quick2code on 2008-Nov-20
Strangely, I actually figured as much. Problem is there may be situations where you want a more dynamic action. Not having a simple function to alter makes it a bit tricky in some circumstances.

One more thing. What's up with the screen tearing in windowed and full screen? I couldn't find a V-Sync option. None of my 2D games have this problem but BlitzMax does. Is it an OpenGL thing? Thanks for your help.
Title: Re: Z Order + Palette Swap
Post by: Moru on 2008-Nov-20
You can make your own sort routine, there is some examples in the forum of how to sort an array. That way you can use your own z-ordering.

If you set the LIMITFPS to something other than -1 it should sync automatically. I'm not sure this works in windowed mode though, at least I haven't seen any games that can do that. On the other hand I haven't been playing the sort of games that bother with that for a while now :-)
Title: Re: Z Order + Palette Swap
Post by: Kitty Hello on 2008-Nov-20
V6 has a SORTARRAY function, that can sort an array of types e.g.
Alternatively you can use 3D and X_SPRITE instead.
Title: Re: Z Order + Palette Swap
Post by: quick2code on 2008-Nov-21
Awesome!!

Not to be rude or nothing, but what about the Palette Swapping? I just figure since Allegro and SDL can do it, it's possible.
Title: Re: Z Order + Palette Swap
Post by: Kitty Hello on 2008-Nov-21
There's no "palette" in GLBasic.