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, when it backs to 0 is not 
perfect aligned. 



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] <javascript:>> 
> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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