Re: Pyglet - Sprite - Integrating into an entity-component system

56 views
Skip to first unread message

"Juan J. Martínez"

unread,
May 22, 2013, 5:12:50 AM5/22/13
to pyglet...@googlegroups.com
On 22/05/13 09:15, Busata wrote:
> [...]
>
> I.e. Anyone has a suggestion on how to split Sprite and its position
> while still being able to add it to the batch?
>

Python uses references so you can have a Sprite in a batch and still
keep it in a different place (ie. a list of entities). When you update
the position of the Sprite in the list, the Bath will draw it in the new
position.

I don't know if there's a better way, but that is how I would do it :)

Regards,

Juan

Busata

unread,
May 22, 2013, 5:24:11 AM5/22/13
to pyglet...@googlegroups.com
Sorry, made a duplicate post as I didn't know sure that it was submitted (until I noticed that it had a delay!). 

I know that's an option, but then my entity can't have a seperate Position component and I'd need to update both. I'd like to avoid this (not a great issue but was curious if it would be possible...)

Op woensdag 22 mei 2013 11:12:50 UTC+2 schreef Juan J. Martínez het volgende:

"Juan J. Martínez"

unread,
May 22, 2013, 5:29:39 AM5/22/13
to pyglet...@googlegroups.com
On 22/05/13 10:24, Busata wrote:
> Sorry, made a duplicate post as I didn't know sure that it was submitted
> (until I noticed that it had a delay!).
>
> I know that's an option, but then my entity can't have a seperate
> Position component and I'd need to update both. I'd like to avoid this
> (not a great issue but was curious if it would be possible...)

Well, that's up to your design. Your Entity class could derive from a
Sprite so you can use the x and y properties of that class as position.

Regards,

Juan


claudio canepa

unread,
May 22, 2013, 6:06:30 AM5/22/13
to pyglet...@googlegroups.com
On Wed, May 22, 2013 at 6:24 AM, Busata <dries...@gmail.com> wrote:
Sorry, made a duplicate post as I didn't know sure that it was submitted (until I noticed that it had a delay!). 

I know that's an option, but then my entity can't have a seperate Position component and I'd need to update both. I'd like to avoid this (not a great issue but was curious if it would be possible...)



You can't avoid that. How else the sprite vertices info in the batch would update ?
pyglet sprites hides the vertices updates, that is, you can update position and let pyglet care to adjust vertices but thats all.  
Reply all
Reply to author
Forward
0 new messages