forked from ayte/PinmikPanik
22 lines
782 B
Python
22 lines
782 B
Python
|
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
|
||
|
depth = -1
|
||
|
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):
|
||
|
self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,0])
|