From 91fda5bbd5eb74709e59055ef9785e9515251dc1 Mon Sep 17 00:00:00 2001 From: Lennert Claeys Date: Tue, 30 Jan 2024 20:32:20 +0100 Subject: [PATCH] Make blood collide with the floor --- src/data/entity/gib/index.ts | 2 +- src/graphics/particles/bloodEmitter.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/data/entity/gib/index.ts b/src/data/entity/gib/index.ts index 1a9c0e4..190643b 100644 --- a/src/data/entity/gib/index.ts +++ b/src/data/entity/gib/index.ts @@ -56,7 +56,7 @@ export class Gib extends Sprite implements TickingEntity { const [x, y] = this.body.precisePosition; this.position.set(x * 6, y * 6); - if (this.bloody && Math.random() > 0.8) { + if (this.bloody && Math.random() > 0.7) { Level.instance.bloodEmitter.spawn( x * 6 + this.offsetX + (Math.random() - 0.5) * 4, y * 6 + this.offsetY + (Math.random() - 0.5) * 4, diff --git a/src/graphics/particles/bloodEmitter.ts b/src/graphics/particles/bloodEmitter.ts index 60a7cf6..d240ff7 100644 --- a/src/graphics/particles/bloodEmitter.ts +++ b/src/graphics/particles/bloodEmitter.ts @@ -4,6 +4,7 @@ import { ParticleEmitter } from "./types"; import { AssetsContainer } from "../../util/assets/assetsContainer"; import { EntityType, HurtableEntity } from "../../data/entity/types"; import { DamageSource } from "../../data/damage/types"; +import { Level } from "../../data/map/level"; const TINT_MAP: Partial> = { [EntityType.Character]: 0xb91e1e, @@ -54,10 +55,17 @@ export class BloodEmitter particle.alpha = Math.min(1, particle.lifetime / 10); - particle.yVelocity += 0.25 * dt; + if ( + !Level.instance.terrain.characterMask.collidesWithPoint( + (particle.x / 6) | 0, + (particle.y / 6) | 0 + ) + ) { + particle.yVelocity += 0.25 * dt; - particle.x += particle.xVelocity * dt; - particle.y += particle.yVelocity * dt; + particle.x += particle.xVelocity * dt; + particle.y += particle.yVelocity * dt; + } } }