mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
remoteMap resolve issue with shrinking viewport when having low FPS
This commit is contained in:
1 parent
619b7972b9
commit
7f6f1d07d7
1 file changed
+9
-4
+9
-4
@@ -296,30 +296,35 @@ function renderLoop(){
|
|||||||
console.log("w");
|
console.log("w");
|
||||||
playerPosition.y -= movement;
|
playerPosition.y -= movement;
|
||||||
if(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize) > 1){
|
if(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize) > 1){
|
||||||
cache.walkUp();
|
for(let i = 0; i < Math.floor(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize)); i++){
|
||||||
|
cache.walkUp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(leftPressed){
|
if(leftPressed){
|
||||||
console.log("a");
|
console.log("a");
|
||||||
playerPosition.x -= movement;
|
playerPosition.x -= movement;
|
||||||
if(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize) > 1){
|
if(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize) > 1){
|
||||||
|
for(let i = 0; i < Math.floor(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize)); i++){
|
||||||
cache.walkRight();
|
cache.walkRight();
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
if(downPressed){
|
if(downPressed){
|
||||||
console.log("s");
|
console.log("s");
|
||||||
playerPosition.y += movement;
|
playerPosition.y += movement;
|
||||||
if(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize) > 1){
|
if(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize) > 1){
|
||||||
|
for(let i = 0; i < Math.floor(Math.abs((playerPosition.y-cachePosition.y)/remoteMapConfig.tileSize)); i++){
|
||||||
cache.walkDown();
|
cache.walkDown();
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
if(rightPressed){
|
if(rightPressed){
|
||||||
console.log("d");
|
console.log("d");
|
||||||
let oldPos = playerPosition.x;
|
let oldPos = playerPosition.x;
|
||||||
playerPosition.x += movement;
|
playerPosition.x += movement;
|
||||||
if(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize) > 1){
|
if(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize) > 1){
|
||||||
|
for(let i = 0; i < Math.floor(Math.abs((playerPosition.x-cachePosition.x)/remoteMapConfig.tileSize)); i++){
|
||||||
cache.walkLeft();
|
cache.walkLeft();
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
// draw map
|
// draw map
|
||||||
drawFromCache();
|
drawFromCache();
|
||||||
|
|||||||
Reference in new issue
Block a user