the Z axis for the sprites ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

the Z axis for the sprites ?

Post by dobro »

I know the first sprite is displayed the most profound, however an option in displaysprite will be a better

example :


DisplaySprite(#eraser ,0,0,[depth ])

the parameter 'depth ' is the Z depth display

Style:

DisplaySprite (#eraser, 0,0,0)
DisplaySprite (#ball, 0,0,2)

#eraser is behind #ball!


be optional as it could keep the current system
with
DisplaySprite (#eraser, 0.0)



it is my idea good? :lol:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

I think it would be better to call it "z-order", not "z-axis". Axis is related with the 3D lib.

I would like to improve your syntax. Here is my

suggestion #1

Code: Select all

DisplaySprite(SpriteID, x, y[, z-order])
Whereas z-order goes from -infinity to +infinity:
0 is the default, -1 is behind the default layer, +4 is in front of the default layer.

To keep the commandset compatible with future versions, here is my
suggestion #2

Code: Select all

DisplaySprite(#eraser, 0, 0)
DisplaySprite(#ball, 0, 0)

SetSpriteOrder(#eraser, -1)
SetSpriteOrder(#ball, 0)

FlipBuffers()
#eraser is behind #ball!
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

yes , why not :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

There are no "layers" for sprites. Thats why it is called 2D ;)
quidquid Latine dictum sit altum videtur
User avatar
TazNormand
User
User
Posts: 27
Joined: Tue May 26, 2009 3:17 pm
Location: France

Post by TazNormand »

OK, no layers for sprites, but why not include it ?

cool would be management of 2 layer (Amiga playfield like), just to say sprite number "n" is top over all others sprites.

Imagine : easier way to make parallax scrollings, ability of a sprite to move alternatively front/behind another one or image (man walking like SOTB in a forest) !!!

Djes on French forum suggest to use linked list, maybe i'll use it
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

it's a completely different approach.

Sprites are just Brushes.
they are no Objects wich have certain positions, you can display the same sprite x times every frame.

when you display a Sprite, the pixels of the Sprites are copied into the screenbuffer, overwriting those wich have been there before.

All Oldskool Mates: forget the Term Sprite!

they are Brushes! or call them Decals, if you like that better.

Imagine : easier way to make parallax scrollings, ability of a sprite to move alternatively front/behind another one or image (man walking like SOTB in a forest) !!!
No, no, no!

this is a problem of YOUR Engine, how you write it, what you enable it to do and what not.

when you want a handling like that, create an appropriate object management.


so please, now all let's repeat in choir:

A Sprite is just a Brush!
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

I don't get it ...

What's the friggin' point of this? The sprites appear in the order you call them in your source code. Why on earth you would need an extra command for that?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

If you need a Z order, just do it in software. Have an array of the sprite numbers you want to draw and the z order. Sort to the Z order then draw them in that order.

You could draw them if reverse Y order if you want them to appear with some kind of depth? Doesn't look good in some cases though.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply