Finding the Player Coordinates Based on the Map Image
[ ] Get the Position of the Background Image
[ ] Get the Position of the Player Image
[ ] Calculate the Relative Position
`// getting player position relative to the background
function getPlayerPosition() {
var background = document.getElementById('background');
var player = document.getElementById('player');
var backgroundRect = background.getBoundingClientRect();
var playerRect = player.getBoundingClientRect();
var playerX = playerRect.left - backgroundRect.left;
var playerY = playerRect.top - backgroundRect.top;
console.log("Player position relative to background: (" + playerX + ", " + playerY + ")");
}`
Current Plan: Code it onto the tutorial and see if the coordinates are shown
Finding the Player Coordinates Based on the Map Image
`// getting player position relative to the background function getPlayerPosition() { var background = document.getElementById('background'); var player = document.getElementById('player');
Current Plan: Code it onto the tutorial and see if the coordinates are shown