On 15 July 2011 07:47, Michael Red <[email protected]> wrote:

> On 15 July 2011 07:40, Michael Red <[email protected]> wrote:
>
>> On 15 July 2011 02:32, Zombie Mariachis <[email protected]>wrote:
>>
>>> Changing the super to "super(Level_1, self).__init__(img, x=x, y=y,
>>> batch=batch)" cleared up the wrong type issue.  Thank you!
>>>
>>> However the sprite's specific def draw(self): instructions aren't
>>> being followed.
>>>
>>> --
>>> 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.
>>>
>>>
>> More likely they are being followed, but not having the expected output.
>> What exactly are you trying to have it do? Because right now, you're
>> blitting an image to the texture at gx, gy. However keep in mind that when
>> you're running __init__, the first thing you do is set x, y = x, y, add the
>> image, then x, y = 0, window_height/2, then gx, gy = x, y.
>>
>> This is because when you're doing the super function, you're calling it
>> with x, y and img. This means that it'll do what it always does. That is,
>> set Sprite._x and Sprite._y to the original x and y, rather than 0 and
>> Window_Height/2. And when you want to move it to 0, Window_Height/2, you
>> should be calling self.set_position(0, Window_Height/2).
>>
>> More importantly, is there really no other way for you to draw this?
>> Because updating the Sprite's texture like this isn't horribly efficient
>> compared to simply drawing the sprite in a different place (I assume the use
>> case will be more complicated than this though). I'm not that good with
>> on-the-fly OpenGL code, so I can only tell you to trial-and-error the
>> numbers in glTranslatef to see if that might be doing it. Try 0, 1, 100,
>> -10, 10, instead of -100.
>>
>> Besides that, right now you're not really, uh, actually updating a
>> texture, come to think of it. The code in sprite.py is convoluted, but I
>> think the fact that you overwrote its draw(self) routine, then actually
>> blitted an image, rather than letting it draw and texture itself, means that
>> you're doing a transform in the texture matrix, but that isn't actually
>> doing anything to any texture, because there are none. This means you should
>> be calling:
>>
>>   super(Level_1, self).draw()
>>
>> either after all your code, instead of (or coupled with) the blitting
>> line, or before it. However it MUST be there in order for you to actually
>> draw the sprite/texture.
>>
>> My suggestion, however, would be to either use Sprites as intended, or
>> simply do the OpenGL bits yourself completely, subclass Window and do this
>> in its on_draw() function. It'll work this way (a bit fiddly), but it's not
>> the most clear code, and any slight change in how Sprites draw might affect
>> this.
>>
>
>
> Oh, uh, an idea just popped up. From what I get of the code, you're either
> trying to somehow draw the sprite (with the texture scrolled to x, y, so
> that you could theoretically move the texture), or draw an image INTO the
> texture at (x,y). For the latter, there's blit_into_texture[1]. You could
> use this on Sprite.texture, however you'd have no real way of rollingback
> changes past saving the texture at the start of the draw() and restoring it
> at the end.
>
> Both need you to call the super's .draw() method, and both would require a
> change in the code of the VERTEX GROUP, which is a transparent thing created
> by the Sprite, that you have little control over. Inserting code into it
> usefully is a matter of basically recreating the Sprite and Vertex Group
> code inside your code, and isn't the best way to go about it.
>
> If you reply with what exactly you're trying to achieve with this code, and
> why you're doing it this way, rather than another, I'll write up a tutorial
> to explain either how to do it, or how to do the same thing using actual
> Sprites.
>


Bleh, forgot the link.

[1] -
http://pyglet.org/doc/api/pyglet.image.AbstractImage-class.html#blit_to_texture

And it was blit_to_texture, rather than into.

-- 
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