Skip to content

Commit

Permalink
Make blood collide with the floor
Browse files Browse the repository at this point in the history
  • Loading branch information
lorgan3 committed Jan 30, 2024
1 parent a5ecc17 commit 91fda5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/data/entity/gib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 11 additions & 3 deletions src/graphics/particles/bloodEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<EntityType, number>> = {
[EntityType.Character]: 0xb91e1e,
Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 91fda5b

Please sign in to comment.