Skip to content
Snippets Groups Projects
Commit 52baf43a authored by Bye's avatar Bye
Browse files

Fix gaps between tiles

parent d7371f9e
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ export default class Player extends Entity {
this.jumping = false;
this.lastFramePos = {x: 0, y: 0};
this.lastFramePos = {x: this.x, y: this.y};
}
draw() {
......
import {Entity, Room} from "../../../hampsterengine/src/things";
import Player from "../objects/player";
import {clone, clonePlayer, abs} from "../extras";
import {clone, clonePlayer, abs, roundToRatio} from "../extras";
import Ground from "../objects/ground";
export const rm_game = new Room();
......@@ -79,7 +79,7 @@ rm_game.step = _=>{
if (abs(player.vy) < 1) player.vy = 0;
if (abs(player.vx) < 1) player.vx = 0;
if ({x: player.x, y: player.y} !== player.lastFramePos) {
if (player.x !== player.lastFramePos.x || player.y !== player.lastFramePos.y) {
player.lastFramePos = {x: player.x, y: player.y};
// Update the camera
canvas.camera.goTo(
......@@ -92,7 +92,7 @@ rm_game.step = _=>{
rm_game.draw = _ => {
canvas.ctx.save();
canvas.ctx.translate(-canvas.camera.x, -canvas.camera.y);
canvas.ctx.translate(roundToRatio(-canvas.camera.x), roundToRatio(-canvas.camera.y));
for (let thing of rm_game.entities) {
thing.draw();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment