Closed MunWolf closed 7 years ago
This should fix the wrapping problem:
Entity.prototype.edges = function() {
if (this.pos.x > world.halfwidth) {
this.pos.x = this.pos.x % world.halfwidth - world.halfwidth;
} else if (this.pos.x < -world.halfwidth) {
this.pos.x = this.pos.x % world.halfwidth + world.halfwidth;
}
if (this.pos.y > world.halfheight) {
this.pos.y = this.pos.y % world.halfwidth - world.halfheight;
} else if (this.pos.y < -world.halfheight) {
this.pos.y = this.pos.y % world.halfwidth + world.halfheight;
}
}
Now you just have to get rid of the border thingy and make the objects render on both sides.
Yeah its the rendering on both sides which I need to do, and I mean to do that in a second PR, I feel this one is already big enough.
The title says most of it.
Other small changes include making the camera follow the player, sadly this breaks the edge by making things suddenly disappear there, I put a bandaid on it by rendering the actual end of the world but this will be fixed in a follow up PR.
Also added a lifetime on the laser, it not being able to cross edges was in my opinion bad but having them persist endlessly until they hit something would make the game way too easy.