Added ceiling to jump calculations, increased the features available when displaying devtools and fixed the toggle glitch

This commit is contained in:
rain
2023-11-16 21:36:27 -06:00
parent 1eef69f514
commit 8013ba262a
6 changed files with 114 additions and 14 deletions
+44 -2
View File
@@ -17,17 +17,59 @@ export class Map {
ctx.fillRect(p.x, p.y, p.w, p.h);
}
}
// TODO: Make ceiling and floor based on hitboxes
floor(x, y, w, h) {
let closestPlatform = game.height;
for(var i = 0;i < this.platforms.length;i++) {
let p = this.platforms[i];
if(y+h <= p.y && x < p.x+p.w && x+w > p.x) {
if(closestPlatform > p.y - h) {
closestPlatform = p.y - h;
if(closestPlatform > p.y) {
closestPlatform = p.y;
}
}
}
return closestPlatform;
}
ceiling(x, y, w, h) {
let closestPlatform = 0;
for(var i = 0;i < this.platforms.length;i++) {
let p = this.platforms[i];
if(y >= p.y+p.h && x < p.x+p.w && x+w > p.x) {
if(closestPlatform < p.y + p.h) {
closestPlatform = p.y + p.h;
}
}
}
return closestPlatform;
}
/*
floor(x, y, w, h) {
let closestPlatform = game.height;
for(var i = 0;i < this.platforms.length;i++) {
let p = this.platforms[i];
if(y+h <= p.y && x < p.x+p.w && x+w > p.x) {
if(closestPlatform > p.y) {
closestPlatform = p.y;
}
}
}
return closestPlatform;
}
ceiling(x, y, w, h) {
let closestPlatform = 0;
for(var i = 0;i < this.platforms.length;i++) {
let p = this.platforms[i];
if(y >= p.y+p.h && x < p.x+p.w && x+w > p.x) {
if(closestPlatform < p.y + p.h) {
closestPlatform = p.y + p.h;
}
}
}
return closestPlatform;
}
*/
}