nalaganje tiled mape. ozadje ni OK.
This commit is contained in:
@@ -115,7 +115,12 @@ class Player {
|
||||
}
|
||||
|
||||
// Kreira sprite
|
||||
const screenPos = this.iso.toScreen(this.gridX, this.gridY);
|
||||
// 🎨 FLAT 2D (NEW!) - Direct screen conversion
|
||||
const tileSize = 48;
|
||||
const screenPos = {
|
||||
x: Math.round((this.gridX * tileSize) + (tileSize / 2)),
|
||||
y: Math.round((this.gridY * tileSize) + (tileSize / 2))
|
||||
};
|
||||
this.sprite = this.scene.add.sprite(
|
||||
screenPos.x + this.offsetX,
|
||||
screenPos.y + this.offsetY,
|
||||
@@ -268,9 +273,11 @@ class Player {
|
||||
|
||||
// Update grid position from pixel position
|
||||
const screenPos = { x: this.sprite.x - this.offsetX, y: this.sprite.y - this.offsetY };
|
||||
const gridPos = this.iso.toGrid(screenPos.x, screenPos.y);
|
||||
this.gridX = Math.floor(gridPos.x);
|
||||
this.gridY = Math.floor(gridPos.y);
|
||||
|
||||
// 🎨 FLAT 2D (NEW!) - Direct grid conversion
|
||||
const tileSize = 48;
|
||||
this.gridX = Math.floor(screenPos.x / tileSize);
|
||||
this.gridY = Math.floor(screenPos.y / tileSize);
|
||||
|
||||
// Check if moving
|
||||
const speed = Math.sqrt(this.velocity.x ** 2 + this.velocity.y ** 2);
|
||||
|
||||
Reference in New Issue
Block a user