1
0
forked from noxious/client

small clean

This commit is contained in:
root 2024-05-01 18:36:19 +02:00
parent 3fe90287c7
commit 29923b57df

View File

@ -7,11 +7,16 @@ import { Sprite, useScene } from 'phavuer'
import { ref } from 'vue' import { ref } from 'vue'
import config from '@/config.js' import config from '@/config.js'
const scene = useScene() /**
* 1 tile is 64x32
* the map is 10x10
* so the map is 640x320
*/
const scene = useScene()
const player = ref(); const player = ref();
let playerX = ref(0) const playerX = ref(0)
let playerY = ref(0) const playerY = ref(0)
// W,S,A,D // W,S,A,D
// Listen for keydown events // Listen for keydown events
@ -51,16 +56,10 @@ scene.input.on('pointerdown', function (pointer) {
playerY.value = gridToScreen(tileX, tileY, config.tile_size).screenY; playerY.value = gridToScreen(tileX, tileY, config.tile_size).screenY;
}); });
/**
* 1 tile is 64x32
* the map is 10x10
* so the map is 640x320
*/
function gridToScreen(x, y, tileSize) { function gridToScreen(x, y, tileSize) {
// Convert grid coordinates to screen coordinates // Convert grid coordinates to isometric screen coordinates
const screenX = x * tileSize.x + tileSize.x / 2; const screenX = (x - y) * tileSize.x / 2;
const screenY = y * tileSize.y + tileSize.y / 2; const screenY = (x + y) * tileSize.y / 2;
return { screenX, screenY }; return { screenX, screenY };
} }