Jump to content

Water wave with Phaser


jdnichollsc
 Share

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.

Link to comment
Share on other sites

  • 1 year later...
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!

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...