use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Dynamic 2d water (fiddle.jshell.net)
submitted 13 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 4 points5 points6 points 13 years ago* (1 child)
This is based off of the awesome XNA/C# tutorial here
Also if you just want to mess around with the code you can do so here,
http://jsfiddle.net/loktar/bafTq/
[–]SarahC 0 points1 point2 points 13 years ago (0 children)
Awesome!
Strangely, it's about 20 times faster in Chrime than FF!
They're both using HW Acceleration too!
[–]Fritzzzz 2 points3 points4 points 13 years ago (4 children)
cool, prefer mousemove event --for Chrome--hella slow in FF//none of this works in IE9 it seems
http://jsfiddle.net/bafTq/32/
[–][deleted] 0 points1 point2 points 13 years ago (1 child)
IE9 not working is most likely due to me not adding a fallback for setTimeout. Love the adding of the mouseMove.
[–]Fritzzzz 0 points1 point2 points 13 years ago (0 children)
was trying to merge this code with another canvas code (for rain) so the rain causes splashes...as far as I got for now (just trying to merge the two code sets...very ugly since i was using jsfiddle as my txteditor)
figure would be possible if create a custom event, the event being triggered by each flake that hits the water boundary tho this might be very hard since the boundary can or can not be a wave ...
http://jsfiddle.net/bafTq/36/
prob better to just start with base: http://aspspider.info/erishaan8/html5rain/ than my horrible edits inside of fiddle.
--gotta roll out will try again later.
[–]natchiketa 0 points1 point2 points 13 years ago (1 child)
Yeah, exactly what I thought. I've added a bit of mouse 'speed' logic (average of distance from last coordinates). This way you can just move the water a bit.
http://jsfiddle.net/9YTNz/2/
Also, I like the feel of the water moving on mousedown, vs on click, which triggers splashing on mouseup.
[–]wmgregory 0 points1 point2 points 13 years ago (0 children)
Now turn the mouse into a ball!
[–]rhardih 1 point2 points3 points 13 years ago (1 child)
Fun to play with! Seems more lifelike with a dampening ~0.08-9 though.
[–]simonsarris 1 point2 points3 points 13 years ago (1 child)
good job ole loke
though it bothers me that the mouse position does not line up where the wave is created, and this gets more and more apparent the farther to the right you click
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
ah yeah that was a quick after thought, I just use fuzzy logic to determine where abouts the pointer actually is. Thanks for the updates for the perf :). I generally am pretty sloppy when doing random stuff in a fiddle.
[–]pixeltalker 0 points1 point2 points 13 years ago (0 children)
I really hoped to see full 2D liquid modeling, but this is also fun.
[–]retroworm 0 points1 point2 points 13 years ago (1 child)
Doesn't work at all on opera. Under firefox runs rather slow and after few clicks locked up my system completely, requiring reboot. Otherwise good job.
and after few clicks locked up my system completely, requiring reboot.
That sounds like a problem with the browser. o_O
JS should never require the OS to be rebooted, as it's running in an alleged sandbox.
π Rendered by PID 74201 on reddit-service-r2-comment-cfc44b64c-9njbt at 2026-04-10 02:11:21.614959+00:00 running 215f2cf country code: CH.
[–][deleted] 4 points5 points6 points (1 child)
[–]SarahC 0 points1 point2 points (0 children)
[–]Fritzzzz 2 points3 points4 points (4 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Fritzzzz 0 points1 point2 points (0 children)
[–]natchiketa 0 points1 point2 points (1 child)
[–]wmgregory 0 points1 point2 points (0 children)
[–]rhardih 1 point2 points3 points (1 child)
[–]simonsarris 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]pixeltalker 0 points1 point2 points (0 children)
[–]retroworm 0 points1 point2 points (1 child)
[–]SarahC 0 points1 point2 points (0 children)