from gamedata.objects.base import BaseObject class Water(BaseObject): def __init__(self,y,game): super().__init__(0,y,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT) self.destinationy = y self.speed = 10 self.depth = 2 self.sprite = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT),flags=game.pygame.SRCALPHA) self.sprite.fill([10,100,180]) self.sprite.set_alpha(200) self.surfacepoints = [] self.nbpoints = 50 for i in range(self.nbpoints): self.surfacepoints.append([game.DISPLAY_WIDTH/self.nbpoints*i,0]) def step(self): self.rect[1] += (self.destinationy-self.rect[1])*self.game.dt*self.speed def draw(self): # Draw the water to the screen self.game.window.blit(self.sprite,[self.rect[0],self.rect[1]-self.game.globals["cameray"]])