Has anyone try to do something with fluids? I want to do something with water, manage its movement and play with presure but i cant find anything in FP related to it. Thanks!
Fluid physics in FP
Hmm, it’s not something that I’ve seen explored much in the FlashPunk scene but I imagine that in the wider Flash scene you’ll find some stuff that could be adapted.
Are you thinking the kind of stuff that’s in PixelJunk Shooter?
Maybe this will help you get started: What is some good examples about creating 2D fluids?
I’ve decided to do something simpler. Imagine you have a room, and it started to fill with water but it’s static, so it would fill the room constantly always at the same level( no waves :P). Any advice?
With no waves, this would simply be an Entity
(we’ll call it FluidVolume
) with a few important properties:
-
density:Number
- The density of the fluid. Higher density means things are more buoyant in the fluid. -
fluidLevel:Number
- The height of the fluid. Increasing this should make the water “rise.”
This is all you’d need for a simple fluid. You’d just slap a texture on it and scale it. Put it behind the foreground, and it could serve as the water for the entire world, if you wanted a fixed water level.
Thanks Zach! The fluid level will increase constantly flooding the room. My idea is to flood the room, if there is a next room the water flow into i.
I’ve found this
-
Flashpunk water demo (Click to add water): http://dl.dropbox.com/u/3527200/watery/index.html
-
Flashpunk water source: http://pastebin.com/zFJLYjpK
This would be a better option for me. It’s like in the middle between the static water and the PixelJunk Shooter behaviour. But i’m having a little problem, I dont know how to handle the collision between water and solids(ground,platforms…). I think this could be fix with mask collision or am i wrong?