Its good... kinda slow... but good nonetheless! Sorry im so uh... "critical"....
Code archives/Graphics/Liquid Fun
This code has been declared by its author to be Public Domain code.
Download source code
| Drag you mouse through some liquid |
SetBuffer BackBuffer() Global CurrentTexture=1,NextTexture=0,TempValue=0 Const MAXWIDTH = 175 Const MAXHEIGHT = 125 ;Change these to get different results Global DEPTH=-800 Global VISCOSITY=128 ;low the number the more water like, hight the number is more like oil Dim WaveMap(4,MAXWIDTH,MAXHEIGHT) While Not KeyDown(1) Cls UpdateWaveMap() Color 255,0,0 Plot MouseX(),MouseY() If MouseDown(1) Then WaveMap(CurrentTexture,MouseX(),MouseY())=DEPTH Flip Wend Function UpdateWaveMap() For y = 1 To MAXHEIGHT-1 For x = 1 To MAXWIDTH-1 n=(WaveMap(CurrentTexture,x-1,y)+WaveMap(CurrentTexture,x+1,y)+WaveMap(CurrentTexture,x,y-1)+WaveMap(CurrentTexture,x,y+1))/2 - WaveMap(NextTexture,x,y) n=n-n/VISCOSITY WaveMap(NextTexture,x,y)=n c = 100-WaveMap(CurrentTexture,x,y) And 255 Color 0,0,c Plot x,y Next Next TempValue=CurrentTexture CurrentTexture=NextTexture NextTexture=TempValue End Function |
Comments
just change the plot to writepixel and use lockbuffer and its really fast, and cool :)
Um, I wouldn't call it fast.
oh also take out cls and flip and setbuffer, lol then its lightning fast. really!
This is pretty cool. I like it thank you for sharing:)
for those interested, the same code in BMax:
Graphics 640,480,32 Global CurrentTexture=1,NextTexture=0,TempValue=0 Const MAXWIDTH = 175 Const MAXHEIGHT = 125 'Change these to get different results Global DEPTH=-800 Global VISCOSITY=128 'low the number the more water like, hight the number is more like oil Global WaveMap[4+1,MAXWIDTH+1,MAXHEIGHT+1] While Not KeyDown(KEY_ESCAPE) Cls UpdateWaveMap() If MouseDown(1) Then WaveMap(CurrentTexture,MouseX(),MouseY())=DEPTH Flip False Wend Function UpdateWaveMap() For y = 1 To MAXHEIGHT-1 For x = 1 To MAXWIDTH-1 n=(WaveMap(CurrentTexture,x-1,y)+WaveMap(CurrentTexture,x+1,y)+WaveMap(CurrentTexture,x,y-1)+WaveMap(CurrentTexture,x,y+1))/2 - WaveMap(NextTexture,x,y) n=n-n/VISCOSITY WaveMap(NextTexture,x,y)=n blue = 100-WaveMap(CurrentTexture,x,y) & 255 SetColor 0,0,blue SetAlpha 0.9 Plot x,y Next Next TempValue=CurrentTexture CurrentTexture=NextTexture NextTexture=TempValue End Function