Nicholls

Water wave with Phaser

Recommended Posts

I achieved this in my Ludum Dare 35 game by using a series of tiny sprites connected by springs and P2 physics.  Then, I "draw" the water on a custom bitmap data sprite using those points and bounding box of the water as a polygon.  Here's the code: https://github.com/Cudabear/ld35/blob/master/src/entity/Water.js

It worked pretty well, though not perfect.  Ideally, the collision would only be one way (the water "points" respond to the player sprite, but not vice versa) because right now the player sprite can get stuck on them.  Couldn't figure out how to do that.  Also, sometimes the water gets way out of control, other times it hardly moves when colliding.  You can play with the elasticity of the springs to make it look as wavy as you want.

Oh, I also use water droplet particles on collision to make things look more natural.

Share this post


Link to post
Share on other sites
On 28/06/2016 at 4:16 PM, Cudabear said:

I achieved this in my Ludum Dare 35 game by using a series of tiny sprites connected by springs and P2 physics.  Then, I "draw" the water on a custom bitmap data sprite using those points and bounding box of the water as a polygon.  Here's the code: https://github.com/Cudabear/ld35/blob/master/src/entity/Water.js

It worked pretty well, though not perfect.  Ideally, the collision would only be one way (the water "points" respond to the player sprite, but not vice versa) because right now the player sprite can get stuck on them.  Couldn't figure out how to do that.  Also, sometimes the water gets way out of control, other times it hardly moves when colliding.  You can play with the elasticity of the springs to make it look as wavy as you want.

Oh, I also use water droplet particles on collision to make things look more natural.

This game is f****** great haha! I love that character. I love that it bends and moulds to the environment, that's awesome. Best one yet!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.