from gamedata.objects.base import BaseObject class Water(BaseObject): def __init__(self,game): self.tileset = game.gameloop.findname("TilesetRenderer")[0] y = self.tileset.layers[0]["surface"].get_height()+8 self.destinationy = y super().__init__(0,y,game,game.globals["cameraw"],game.globals["camerah"]) self.speed = 10 self.depth = 2 self.sprite = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)) self.sprite.set_alpha(180) white = [245,237,186] cyan = [126,196,193] blue = [52,133,157] dark = [23,67,75] slides = [[3,white],[8,cyan],[2,blue],[5,cyan],[2,blue],[2,cyan],[120,blue],[5,dark],[10,blue],[20,dark],[10,blue]] self.slides = [] offset = 0 for i in slides: surf = self.game.pygame.Surface((game.DISPLAY_WIDTH,i[0])) surf.fill(i[1]) self.slides.append([surf,offset]) offset+=i[0] def step(self): self.rect[1] += (self.destinationy-self.rect[1])*self.game.dt*self.speed def draw(self): # Prepare the sprite self.sprite.fill([23,67,75]) for i in self.slides: posy = min(self.rect[1]-self.game.globals["cameray"],0)+i[1] self.sprite.blit(i[0],[0,posy]) # Draw the water to the screen drawy = max(self.rect[1]-self.game.globals["cameray"],0) self.game.window.blit(self.sprite,[0,drawy])