This commit is contained in:
2026-06-24 19:56:56 +03:00
commit e258330757
6 changed files with 188 additions and 0 deletions

40
platform.js Normal file
View File

@@ -0,0 +1,40 @@
window.PLATFORMS_LIST = []
function getPlatforms() {
return PLATFORMS_LIST;
}
/**
* Spawn a platform in the world and append it to the platforms list for collision checking
* @param {number} X The X Coordinate of the platform
* @param {number} Y The Y Coordinate of the platform
*/
function spawnPlatform(X, Y) {
// Randomize Width a little bit
const DEFAULT_WIDTH = 125;
const newWidth = DEFAULT_WIDTH + ( (Math.random() - 0.5) * DEFAULT_WIDTH )
const platform = {
position: {
x: X,
y: Y,
},
size: {
x: newWidth,
y: 15,
},
step() {
},
draw() {
fill(newWidth, newWidth, 255)
rect(this.position.x, this.position.y, this.size.x, this.size.y)
}
}
PLATFORMS_LIST.push(platform);
return platform;
}