This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
billysback's profile picture

Water! - Kinda Like Fire! But With Water...

Started by billysback, 14 September 2013 - 04:14 AM
billysback #1
Posted 14 September 2013 - 06:14 AM
This is a bit like Gopher's Fire! but instead it shows a constant stream of flowing water.

It's also slightly less complex than Gopher's, all it technically does is draw the sine graph with varying transformations, but after a lot of tweaking of settings I finally got something that I at least think looks representable.


(NOTE: the gif is about 4x slower than it actually runs at, perhaps even slower than that, and its a tiny bit glitchy, but it should give you an idea of how it flows.)
Spoiler

Here's the paste:
http://pastebin.com/SYeftZTM

Or if you prefer hastebin:
http://hastebin.com/buqeriwoja.lua

Just thought I'd share it, feel free to toggle the settings, here's a list of key variables and what they change:
Spoiler"damt = 8" - the speed at which the waves move up and down
"dskip = 0" - the amount the waves skip, to stop stationary movement at slower speeds
"dmax = 45" - the min and max of the waves height

"stcmax = 90" - the max width of the waves
"stcmin = 75" - the min width of the waves
"stcamt = 2" - the speed at which the waves increase/decrease

"offset = offset + 1" (in draw()) - change the " + 1 " to change the speed at which the waves move

also, in the actual equation-thingy

(math.max((math.sin((x-getOffset())/stretch)*(dither))-0.5) + math.floor(height/2))
flip the sign in "x-getOffset()" to change the direction of the waves.
also note that I realize math.max() doesn't do anything, but that's to make it easier to test things.
H4X0RZ #2
Posted 14 September 2013 - 06:24 AM
Looks good
ElectricOverride #3
Posted 14 September 2013 - 06:18 PM
Sweet.
Zudo #4
Posted 15 September 2013 - 02:17 AM
May I use this as a "screensaver" please?
TheOddByte #5
Posted 15 September 2013 - 03:30 AM
Pretty nice, Thought someone would create rain and "set fire to the rain" :P/>
+1 anyways since it looks really nice :)/>
billysback #6
Posted 15 September 2013 - 06:57 AM
May I use this as a "screensaver" please?
of course, that's pretty much what I had in mind when I made it

Thanks for the comments everyone else :)/>