This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,5 +1,5 @@
#!/usr/bin/env python
"""pygame.examples.liquid
""" pygame.examples.liquid
This example demonstrates a simplish water effect of an
image. It attempts to create a hardware display surface that
@@ -13,24 +13,24 @@ pygame to compare the results. I didn't bother porting the text and
sound stuff, that's an easy enough challenge for the reader :]
"""
import pygame as pg
import os
from math import sin
import pygame
import time
main_dir = os.path.split(os.path.abspath(__file__))[0]
def main():
# initialize and setup screen
pygame.init()
screen = pygame.display.set_mode((640, 480), pygame.DOUBLEBUF)
pg.init()
screen = pg.display.set_mode((640, 480), pg.HWSURFACE | pg.DOUBLEBUF)
# load image and quadruple
imagename = os.path.join(main_dir, "data", "liquid.webp")
bitmap = pygame.image.load(imagename)
bitmap = pygame.transform.scale2x(bitmap)
bitmap = pygame.transform.scale2x(bitmap)
imagename = os.path.join(main_dir, "data", "liquid.bmp")
bitmap = pg.image.load(imagename)
bitmap = pg.transform.scale2x(bitmap)
bitmap = pg.transform.scale2x(bitmap)
# get the image and screen in the same format
if screen.get_bitsize() == 8:
@@ -44,15 +44,10 @@ def main():
# mainloop
xblocks = range(0, 640, 20)
yblocks = range(0, 480, 20)
stop_events = pygame.QUIT, pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN
clock = pygame.Clock()
stopevents = pg.QUIT, pg.KEYDOWN, pg.MOUSEBUTTONDOWN
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type in stop_events:
for e in pg.event.get():
if e.type in stopevents:
return
anim = anim + 0.02
@@ -62,12 +57,13 @@ def main():
ypos = (y + (sin(anim + y * 0.01) * 15)) + 20
screen.blit(bitmap, (x, y), (xpos, ypos, 20, 20))
pygame.display.flip()
pg.display.flip()
time.sleep(0.01)
if __name__ == "__main__":
main()
pygame.quit()
pg.quit()
"""BTW, here is the code from the BlitzBasic example this was derived