Overflown/gamedata/objects/ingame/water.py

45 lines
1.5 KiB
Python
Raw Normal View History

2021-11-16 11:32:31 +01:00
from gamedata.objects.base import BaseObject
class Water(BaseObject):
2021-11-21 12:28:27 +01:00
def __init__(self,game):
self.tileset = game.gameloop.findname("TilesetRenderer")[0]
2021-11-24 07:54:47 +01:00
y = self.tileset.layers[0]["surface"].get_height()+8
2021-11-21 12:28:27 +01:00
self.destinationy = y
2021-11-16 11:32:31 +01:00
super().__init__(0,y,game,game.globals["cameraw"],game.globals["camerah"])
2021-11-16 11:32:31 +01:00
self.speed = 10
2021-11-16 23:38:36 +01:00
self.depth = 2
2021-11-19 14:26:54 +01:00
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]
2021-11-16 11:32:31 +01:00
def step(self):
self.rect[1] += (self.destinationy-self.rect[1])*self.game.dt*self.speed
def draw(self):
2021-11-19 14:26:54 +01:00
# 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])
2021-11-16 11:32:31 +01:00
# Draw the water to the screen
2021-11-19 14:26:54 +01:00
drawy = max(self.rect[1]-self.game.globals["cameray"],0)
self.game.window.blit(self.sprite,[0,drawy])