From cb4e61ff51c939f6b28e62b083f80d4b815ef515 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 9 Aug 2015 17:26:41 +0200 Subject: [PATCH] Don't let bubbles escape the liquid they are in. --- src/defs.h | 1 + src/particles.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/defs.h b/src/defs.h index c8b468f..d358d3e 100644 --- a/src/defs.h +++ b/src/defs.h @@ -252,6 +252,7 @@ const char skill[][10] = { #define PAR_WEIGHTLESS 1 #define PAR_COLLIDES 2 +#define PAR_LIQUID 4 /* ######### effect flags ########### */ diff --git a/src/particles.cpp b/src/particles.cpp index 66595ab..ea38ede 100644 --- a/src/particles.cpp +++ b/src/particles.cpp @@ -94,7 +94,7 @@ void addBubble(float x, float y) { if ((Math::prand() % 50) == 0) { - map.addParticle(x + Math::prand() % BRICKSIZE, y + 19, 0, Math::rrand(-3, -1), Math::rrand(30, 90), graphics.red, graphics.getSprite("Bubble", true), PAR_COLLIDES + PAR_WEIGHTLESS); + map.addParticle(x + Math::prand() % BRICKSIZE, y + 19, 0, Math::rrand(-3, -1), Math::rrand(30, 90), graphics.red, graphics.getSprite("Bubble", true), PAR_COLLIDES | PAR_WEIGHTLESS | PAR_LIQUID); } } @@ -187,6 +187,14 @@ void doParticles() } } + if (particle->flags & PAR_LIQUID) + { + if (!map.isLiquid(x, y)) + { + particle->health = 0; + } + } + if (particle->health > 0) { previous = particle; -- 2.39.5