2
"""This examples demonstrates a simplish water effect of an
3
image. It attempts to create a hardware display surface that
4
can use pageflipping for faster updates. Note that the colormap
5
from the loaded GIF image is copied to the colormap for the
8
This is based on the demo named F2KWarp by Brad Graham of Freedom2000
9
done in BlitzBasic. I was just translating the BlitzBasic code to
10
pygame to compare the results. I didn't bother porting the text and
11
sound stuff, that's an easy enough challenge for the reader :]"""
14
from pygame.locals import *
18
#initialize and setup screen
20
screen = pygame.display.set_mode((640, 480), HWSURFACE|DOUBLEBUF, 8)
23
imagename = os.path.join('data', 'liquid.bmp')
24
bitmap = pygame.image.load(imagename)
26
#get the image and screen in the same format
27
if screen.get_bitsize() == 8:
28
screen.set_palette(bitmap.get_palette())
30
bitmap = bitmap.convert()
36
while not pygame.event.peek([QUIT, KEYDOWN, MOUSEBUTTONDOWN]):
38
for x in range(0, 640, 20):
39
for y in range(0, 480, 20):
40
xpos = (x + (sin(anim + x * .01) * 15)) + 20
41
ypos = (y + (sin(anim + y * .01) * 15)) + 20
42
screen.blit(bitmap, (x, y), (xpos, ypos, 20, 20))
47
"""BTW, here is the code from the BlitzBasic example this was derived
48
from. This code runs a little faster, yet reads a lot slower. again
49
i've snipped the sound and text stuff out.
50
-----------------------------------------------------------------
51
; Brad@freedom2000.com
53
; Load a bmp pic (800x600) and slice it into 1600 squares
55
SetBuffer BackBuffer()
57
pic=LoadAnimImage(bitmap$,20,15,0,1600)
59
; use SIN to move all 1600 squares around to give liquid effect
61
f=0:w=w+10:If w=360 Then w=0
62
For y=0 To 599 Step 15
63
For x = 0 To 799 Step 20
64
f=f+1:If f=1600 Then f=0
65
DrawBlock pic,(x+(Sin(w+x)*40))/1.7+80,(y+(Sin(w+y)*40))/1.7+60,f