On Tue, Jun 16, 2015 at 5:21 PM, NiBE <[email protected]> wrote:

> HI,
> thanks for the replay I tried this one:
>
> def update(dt):
>       self.base.x = -((-(self.base.x - 15 * dt)) % base_shift)
>
> but even if it works it doesn't seem to be smooth,
>
> I noticed that scheduling updates with clock.schedule is not smooth (in
windows at least)

If you are using clock.schedule, you may change to clock.schedule_interval
with a small dt, say 1/60 or less


>  when it backs to 0 is not perfect al
>
>
The expression in update does in fact returns to zero, if visually you see
otherwise, it should be:

  other parts in your code changes self.base.x

  if your code changes the modelview matrix at any time, your modelview
matrix is not what it should be at the time you draw the piece in question




>
> On Tuesday, June 16, 2015 at 9:24:41 PM UTC+2, claudio canepa wrote
>>
>> maybe
>>
>> def update(self, dt):
>>       self.base.x =  (self.base.x - 30 * dt) % self.base.shift
>>
>> ?
>>
>>
>> On Tue, Jun 16, 2015 at 4:07 PM, NiBE <[email protected]> wrote:
>>
>>>
>>> HI,
>>> I'm trying to convert a simple game written in pygame in pyglet. I
>>> almost figure out everything, but now I'm facing this situation, I have a
>>> background sprite like this example:
>>>
>>>
>>> <https://lh3.googleusercontent.com/-2dm2ybJClP4/VYBzG7LGq2I/AAAAAAAAAAM/26lLN4emb50/s1600/base.png>
>>>
>>> In my pygame code I use to write this to let it scrolls smoothly in the
>>> background:
>>>
>>>
>>> base_shift = self.graphic.IMAGES['base'].get_width() - 
>>> self.COMMON_CONST['screenWidth']
>>> while True:
>>>     base_x = -((-base_x + 3) % base_shift)
>>>     self.screen.blit(self.graphic.IMAGES['base'], (base_x, y))
>>>
>>> Basically the image is longer than the actual screen and once it passes
>>> the delta value between image X and screen X, the image is set to 0 again.
>>>
>>>
>>> I'm trying to do the same in pyglet inside the *def update(self, dt):*
>>> function but I have no idea exactly how to do it.
>>>
>>> I mean I understand the meaning of dt but still I can't get it.
>>>
>>> To move the image now I do something like this:
>>>
>>>
>>> def update(self, dt):
>>>     self.base.x -= 30 * dt
>>>
>>> Of course this will continue to move and it does not reset his position.
>>> How can I replicate the behavior that I have done in pygame?
>>>
>>> I'm sorry maybe this is a stupid question, I'm a newbie trying to learn.
>>>
>>>
>>> thanks a lot
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pyglet-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pyglet-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to