from gamedata.objects.base import BaseObject class Clouds(BaseObject): def __init__(self,game,minwidth,speed=30,cameraratio=1,spritename="clouds.png"): super().__init__(0,0,game) self.sprite = game.sprite_lib[spritename] self.speed = speed self.minwidth = minwidth self.cameraratio = cameraratio self.depth = -2 self.horoffset = 0 self.handlepause = True def step(self): self.horoffset+=self.game.dt*self.speed def draw(self): offset = (self.horoffset-self.game.globals["camerax"]*self.cameraratio)%self.sprite.get_width() nbsprites = round((self.minwidth+offset)//self.sprite.get_width()+2) for i in range(nbsprites): self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,-self.game.globals["cameray"]*self.cameraratio])