How can I create moving water (2D) in BlitzMax?

BlitzMax Forums/BlitzMax Programming/How can I create moving water (2D) in BlitzMax?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Like this?
Graphics 640,480

Local image:TImage = LoadImage(MakeWavePix(64,64,16))

Local a:Float = 0
Local offx:Int = 0
Local offy:Int = 0

While Not KeyHit(KEY_ESCAPE)

	Cls

	a:+5
	offx = (offx + 1) Mod 64
	offy =  8+Sin(a)*8
	
	For Local x:Int = -64 To GraphicsWidth() Step 64
		DrawImage image,x+offx,GraphicsHeight()-64+offy
	Next

	Flip
	
Wend


Function MakeWavePix:TPixmap(w:Int,h:Int,wh:Int,red:Int=100,grn:Int=120,blu:Int=200)

	Local p:TPixmap = CreatePixmap(w,h,PF_RGBA8888)
	
	Local argb0:Int = $FF000000 | (red Shl 16) | (grn Shl 8) | blu
	Local argb1:Int = $00000000 | (red Shl 16) | (grn Shl 8) | blu
		
	For Local x:Int = 0 Until p.width
		Local a:Float = (x/Float(p.width)) * 360.0
		Local c:Int = (Cos(a)*0.5*wh) + wh
		For Local y:Int = 0 Until p.height
			If y<c
				p.WritePixel(x,y,argb1)
			Else
				p.WritePixel(x,y,argb0)
			EndIf
		Next
	Next

	Return p

EndFunction