Prettier water

This commit is contained in:
theo@manjaro 2021-11-19 14:26:54 +01:00
parent d83e23cd43
commit d48cf64816
2 changed files with 32 additions and 11 deletions

View File

@ -4923,7 +4923,17 @@
},
{"name": "Balloon", "id": 36, "_eid": "16494694", "x": 1296, "y": 176, "originX": 0, "originY": 0},
{"name": "Balloon", "id": 37, "_eid": "16494694", "x": 1360, "y": 160, "originX": 0, "originY": 0},
{"name": "Balloon", "id": 38, "_eid": "16494694", "x": 1264, "y": 128, "originX": 0, "originY": 0}
{"name": "Balloon", "id": 38, "_eid": "16494694", "x": 1264, "y": 128, "originX": 0, "originY": 0},
{
"name": "Spring",
"id": 39,
"_eid": "24018769",
"x": 912,
"y": 336,
"originX": 0,
"originY": 0,
"values": {"angle": 180, "strength": 7}
}
]
}
]

View File

@ -11,20 +11,31 @@ class Water(BaseObject):
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.sprite = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
self.sprite.set_alpha(180)
self.surfacepoints = []
self.nbpoints = 50
for i in range(self.nbpoints):
self.surfacepoints.append([game.DISPLAY_WIDTH/self.nbpoints*i,0])
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
self.game.window.blit(self.sprite,[self.rect[0],self.rect[1]-self.game.globals["cameray"]])
drawy = max(self.rect[1]-self.game.globals["cameray"],0)
self.game.window.blit(self.sprite,[0,drawy])