I am trying to achieve Legends of Yore like movement. I know I need to get the offset and add that to the drawing coordinates but I just can’t seem to get it working.
Here is my current code:-
public void draw(Graphics g) {
xOff = 1184 - Player.x * tile;
yOff = 1184 - Player.y * tile;
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[x].length; y++) {
switch(map[y][x]) {
case 1:
g.drawImage(wall, x * tile + xOff * tile, y * tile + yOff * tile, null);
break;
case 2:
g.drawImage(key, x * tile + xOff * tile, y * tile + yOff * tile, null);
break;
}
}
}
}
The 1184 is the world coordinates if you’re wondering too.
If anyone can help me, please leave a reply.
-Shannon