GLBasic, 2008/2009 plans

Previous topic - Next topic

Ian Price

What about Z ordering sprites? I can't remember if that's in already, but could it be added if not?
I came. I saw. I played.

Hemlos


Quote from: Kitty Hello on 2008-Aug-07
1. OPENFILE
2. AUTOPAUSE
3. *gulp* :D

1. done
2. done
3. done..no gulping ;)

Always on top Funktion, Code ist in UserLibs:

ALWAYSONTOP()
Bing ChatGpt is pretty smart :O

Kitty Hello

z-order is order of drawing. There is no "sprite" in GLBasic, just "Drawing" them.

Ian Price

That's what I meant really. Adding a priority/order to the drawing process. Possible?
I came. I saw. I played.

Kuron

Quote from: Ian Price on 2008-Aug-10
That's what I meant really. Adding a priority/order to the drawing process. Possible?
Shouldn't this be part of the sprite manager in the game engine you write? 

Kitty Hello

Someone has started a 2D Entity System in the Code snippets. That's basically what you want.

Ian Price

QuoteShouldn't this be part of the sprite manager in the game engine you write?

I already DO have an ordering system, I just like the simplicity of a hard-coded in the language Z-order.

Div Games Studio did it beautifully over 10 years ago and very few languages have it. It makes things a lot easier for people new to coding that want to create simple 3D effects.

I thought this was an open forum for expressing ideas. Maybe I was wrong.
I came. I saw. I played.

Moru

I want Y ordering of sprites, am I strange? :-)

Kuron

QuoteI thought this was an open forum for expressing ideas.
Indeed it is, my apologies for expressing one.

Kitty Hello

The problem is, that I don't have sprites anywhere. And if I had to store sprite position/rotation/scaling and all for Z-sorting, I'd have to implement a whole lot of new commands, as it was introduced with the EntitySystem. So, I think it would be better to write your own code (it's quite easy) and share that here :P

AndyH

A sprite system in GLB would be a nice game saving device to have, but I guess there's many things you might want to be able to do with it and perhaps writing your own gives more flexibility.

Talking of ordering, if a sprite system is too much, it would be nice to have some built in methods to make writing your own even easeir.  For example, I think most people use a TYPE array to store a list of sprites with DIMPUSH and DIMDEL for adding/removing items in the array and FOREACH to step through each element in the array.  What we're missing is a nice easy way to sort the array in to a preferred order.

I wonder if something like the following could be added to GLB?

TYPE sprite
sprnum ; x ; y
ENDTYPE

local mySprite1 AS sprite
local mySprite2 AS sprite
local mySprite3 AS sprite

mySprite1.y = 100
mySprite2.y = 50
mySprite3.y = 200

DIMPUSH Sprites[], mySprite1
DIMPUSH Sprites[], mySprite2
DIMPUSH Sprites[], mySprite3

DIMSORT( Sprites[],  Sprites[].y )  // sort Sprites[] array using Sprites[].y


Sebastian


Kuron

ARB has always been OpenGL's worst enemy.

Kitty Hello

Noone cares here. It's just another way of writing code, it has nothing to do with features of OpenGL. Just the API didn't change. I'm glad.

Sorting by member? Sorting is definitely something I should look for. Nice idea you have there.
Would work for types, only, but it's very usefull.
Or something like a "sort by function" like:

Code (glbasic) Select

SORTER MySort: a AS TType, b AS TType
   return a.y > b.y
ENDSORTER

DIMSORT(myarray[], MySort)

Moru

I use this for sprites, stolen from the forum somewhere

Code (glbasic) Select
// ------------------------------------------------------------- //
// -=#  QUICKSORT  #=-
// ------------------------------------------------------------- //
FUNCTION quicksort_y: array[] AS NPC, low, high

LOCAL lo, hi, piv, t AS NPC

lo = low
hi = high
piv = array[high].y
WHILE TRUE
WHILE array[lo].y < piv
INC lo, 1
WEND
WHILE array[hi].y > piv
DEC hi, 1
WEND
IF lo <= hi
t = array[lo]
array[lo] = array[hi]
array[hi] = t
INC lo, 1
DEC hi, 1
ENDIF
IF lo > hi THEN BREAK
WEND
IF hi > low THEN quicksort_y(array[], low, hi)
IF lo < high THEN quicksort_y(array[], lo, high)

ENDFUNCTION // QUICKSORT