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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.