Modeling blood in a box2d world

I’m writing a platform game and I’m using box2d to handle all the physics there. Now I’m adding the hero death animation and I want when he dies, he bleed to dead (hehehe) in a kind of realistic way.

I mean, it would be great is his blood is splashed around the box2d world. For example, when he falls in spikes, I’m trying to splash his blood over those spikes.

The spikes are modeled with a box2d polygon shape, but i don’t know how to emulate the liquid thing in box2d. I also have been trying to use particles, but i don’t know how to link the particle system to the box2d world.

I’ve seen some games doing this, but I don’t know if they use some tricks to create the effect. I’m kind of stuck with this.

How do you model blood in your games?

Usually you can just add blood spots to spikes, if you want to liquid, check out this, but it’s more like liquid physics, which means your hero will be bleeding so much that make him float :slight_smile:

You could do it by spawning circular bodies as particles for the blood effect, and then render them with marching squares algorithm to make them look like fluid.

@nite, very useful link, thanks!

@KJS cool idea! That would create a good liquid illusion, but the problem to link those particles to the box2d world remains, or you are suggesting to create a box2d body for each particle and change their shape dynamically according to the marching square algorithm calculations? I bet that would have a huge impact in performance.

By the way, recently I’ve found a game which use the following strategy to model blood:

  1. Create around 7 tiny red squares (they look more like dots, but they are squares).
  2. Create a box2d body (whit its equivalent box2d square shape) for every one of them
  3. Apply a little impulse to those squares when the player dies… so it looks like a few spots of blood go out from the player and fall in the box2d world.

This is not exactly what i was looking for, but looks like an inexpensive way to achieve the result. But I believe using the liquid library which nite linked in his answer is a much better way to create a realistic effect.

@viktor

What I ment is using box2d for those circular bodies, so you get proper physics simulation. There’s no need to scale the physics bodies or change their shape, you just need to render the bodies differently. For this you need the marching squares algorithm, but it’s just for rendering.

@KJS Oh, ok, I understand. I’m going to try it. Thanks!