From 8458753ce29b193ecbf380bc17ca855ee0e8419c Mon Sep 17 00:00:00 2001 From: rain Date: Fri, 17 Nov 2023 11:12:32 -0600 Subject: [PATCH] Updated player dev hitboxes to be drawn and detected based on entity hitbox instead of coords/size --- js/entities/player.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/entities/player.js b/js/entities/player.js index ba9fad8..d0f69c8 100644 --- a/js/entities/player.js +++ b/js/entities/player.js @@ -119,24 +119,25 @@ export class Player { if(hitboxes) { let hitbox = this.hitbox(this); let padding = this.padding(this.width, this.height); - ctx.fillStyle = 'blue'; + ctx.fillStyle = 'green'; ctx.globalAlpha = 0.4; ctx.fillRect(hitbox.l, hitbox.t, hitbox.r-this.x-padding.l, hitbox.b-this.y-padding.t); - ctx.fillStyle = 'green'; + ctx.fillStyle = 'red'; // Mark the Top ctx.fillRect(hitbox.l, hitbox.t, hitbox.r-this.x-padding.l, 2); - ctx.fillStyle = 'red'; // Mark the Bottom ctx.fillRect(hitbox.l, hitbox.b, hitbox.r-this.x-padding.l, -2); // Draw Floor Marker - let floor = this.map.floor(this.x, this.y, this.width, this.height); + //let floor = this.map.floor(this.x, this.y, this.width, this.height); + let floor = this.map.floor(hitbox.l, hitbox.t, hitbox.r-hitbox.l, hitbox.b-hitbox.t); ctx.fillStyle = 'yellow'; ctx.fillRect(this.x, floor, this.width, 10); // Draw Ceiling Marker - let ceiling = this.map.ceiling(this.x, this.y, this.width, this.height); + //let ceiling = this.map.ceiling(this.x, this.y, this.width, this.height); + let ceiling = this.map.ceiling(hitbox.l, hitbox.t, hitbox.r-hitbox.l, hitbox.b-hitbox.t); ctx.fillRect(this.x, ceiling, this.width, 10); } ctx.globalAlpha = 1;