Open Cazka opened 1 year ago
I noticed that, what will i change? you can do the same as on diepbox
It totally should switch to memory interaction. going off of canvas/rendering is probably the most ineffective and unstable way to do things. (specially on low-end pc's).
Looking forward to it :)
I would be willing to help with development. I have been experimenting on this game lately.
Discord contact is in my bio.
I have an idea: for game modes you can manually (in script) set the size of the arena and for the sandbox detect the number of players and what size it corresponds to
detecting the number of players is also challenging. But I agree, that we could hardcode de arenasizes for the other game modes
i try something
I had to redo the camera because it was not the right coordinate and the arena I just changed the size
class Camera {
#position;
constructor() {
game.on('frame_end', () => {
const playerPos = player.position;
const topLeft = Vector.subtract(playerPos, new Vector(window.innerWidth / 2, window.innerHeight / 2));
const bottomRight = Vector.add(playerPos, new Vector(window.innerWidth / 2, window.innerHeight / 2));
this.#position = new Vector(topLeft.x, bottomRight.y);
});
}
get position() {
return this.#position;
}
}
class Arena {
#size = 1;
constructor() {
setInterval(() => {
if (player.gamemode === 'sandbox') {
const toggleButton = document.querySelector("body > d-base").shadowRoot.querySelector("d-game").shadowRoot.querySelector("#user-list-toggle");
const matches = toggleButton.textContent.match(/\d+/);
const number = parseInt(matches[0]);
this.#size = Math.floor(25 * Math.sqrt(Math.max(number, 1))) * 100; // I used ABC's diep Custom for this part but its working
console.log(`size: ${this.#size}`)
} else {
this.#size = 22300;
}
}, 16);
}
/**
* @returns {number} The Arena size in arena units
*/
get size() {
return this.#size;
}
/**
*
* @param {Vector} vector The vector in [0, 1] coordinates
* @returns {Vector} The scaled vector in [-Arena.size/2, Arena.size/2] coordinates
*/
scale(vector) {
const scale = (value) => Math.round(this.#size * (value - 0.5));
return new Vector(scale(vector.x), scale(vector.y));
}
/**
*
* @param {Vector} vector - The scaled vector in [-Arena.size/2, Arena.size/2] coordinates
* @returns {Vector} The unscaled vector in [0, 1] coordinates
*/
unscale(vector) {
const unscale = (value) => value / this.#size + 0.5;
return new Vector(unscale(vector.x), unscale(vector.y));
}
}
for sandbox: on the other hand the problem is that the players will have to be alive to display the number of players unless we detect the "teleportation" of the player's arrow on the minimap when a new player connects
since they removed minimap viewport #64, it is not possible to determine the arena size anymore.
Should diepAPI transition from canvas based to memory based api?