2021-09-14 16:09:42 +02:00
|
|
|
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
|
2021-09-16 08:19:35 +02:00
|
|
|
self.depth = -2
|
2021-09-14 16:09:42 +02:00
|
|
|
self.horoffset = 0
|
|
|
|
|
|
|
|
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):
|
2021-09-16 08:19:35 +02:00
|
|
|
self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,-self.game.globals["cameray"]*self.cameraratio])
|