Hello. If I understand correctly your situation, you can easily do
that using ordered groups and it really isn't that complicated.

If it's a side-scroller that you want, I think I might be able to lend
you a hand with this little code:
#
#
#
import pyglet

batch = pyglet.graphics.Batch()# I defined a batch(a "box" where you
store Sprites)...

"""What follows is so we can have a very specific order in which we
want the elements of the batch to be drawn(kind of like using
layers)."""

"""Now, I create two groups, unoe called  background,  and another
called foreground, and I give them number labels, 0 and 1.  0  will
always be drawn first and  1  one will always be drawn later; to put
it more succintly, background  is always drawn first and  foreground
second."""

background = pyglet.graphics.OrderedGroup(0)
foreground = pyglet.graphics.OrderedGroup(1)


"""I define my sprites:"""

image1_image = pyglet.image.load('image1.jpg')#just put an image named
image 1 somewehere in the same folder as this program(a jpg in this
case).

sprite1 = pyglet.sprite.Sprite(image1_image, x=0, y=0, batch=batch,
group = background)#Notice how I had to specify the batch I'm using,
and the group that background goes in, in the last two fields of this
line.

image2_image = pyglet.image.load('image2.jpg')#just put an image named
image 2 somewehere in the same folder as this program(a jpg in this
case).

sprite2 = pyglet.sprite.Sprite(image2_image, x=0, y=0, batch=batch,
group = foreground)#Notice how I had to specify the batch I'm using,
and the group that background goes in, in the last two fields of this
line.

window = pyglet.window.Window(800,533,resizable=True)

@window.event
def on_draw():
    batch.draw()#Basically you draw the box, which draws the sprites
you want, and in the order of their respective groups' order.

pyglet.app.run()
#
#
#


Hoped that helped you. Using batches and groups is not as daunting as
it seems at first hand, just give it a spit with some help of this
little code




On Oct 4, 6:01 am, Ben Sizer <[email protected]> wrote:
> On Oct 3, 10:26 am, Florian Bösch <[email protected]> wrote:
>
> > On Oct 3, 12:18 am, Ben Sizer <[email protected]> wrote:> Am I right in 
> > thinking there is no explicit depth-buffer support in
> > > pyglet?
>
> > I've got no idea what you mean by "explicit depth-buffer"
>
> I mean explicit support for the depth buffer, not support for an
> explicit depth buffer (whatever that may be!)
>
> > However, you could enable depth tests and give your sprites different
> > Z values to get opengl to draw some on top of others.
> > You could use ordered groups if that fits your fancy.
>
> Basically I'm asking if someone has done this already - I am not
> familiar enough with how to write my own groups or how to hack the
> pyglet sprites to get them to use a z-value. I can enable the depth
> buffer and testing without a problem - the issue is how to get
> pyglet's sprite system to make use of this.
>
> > You could write a vertex shader that derives the Z value from they Y
> > value, thereby making unecessary to maintain Z yourself (assuming you
> > mean ordering by Y
> > You could setup a slightly skewed orthographic projection where the Y
> > component would contribute to the modelview transformed Z
>
> This is all a bit complex for me, unfortunately. I just want to be
> able to render a sprite using the normal pyglet calls with an
> arbitrary z value of my choice, no shaders or custom projections. Can
> you or anybody else suggest a method for me to be able to do this?
>
> --
> Ben Sizer

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to