Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / smooth scrolling tiles (embarassing)

Author
Message
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 3rd Sep 2005 13:03
Okay, this question coming from the self confessed "master of tile maps" is totally embarassing. I am having trouble calculating the correct offset to scroll what is for all intents and purposes a tilemap.

Its the mini map on my 3d game. The dungeons are laid out in a tile-like array which makes it easy (supposedly >>. I know how to smooth scroll a normal tile map, generally you calculate the offset for the tile like player_x % TileSize and player_y % TileSize for the horizontal offset. But nothing I am doing seems to make my mini map scroll.. I think it has something to do with the dungeon tiles being one size and then the tiles of the minimap being another.

The size of a dungeon square is 79 units and the size of a minimap tile (not zoomed in) is 10px. I have tried

offsetx = abs(PlayerChar.x) % TS-1;
offsety = abs(PlayerChar.z) % TS-1;

and

offsetx = abs(PlayerChar.x) % TileSize-1;
offsety = abs(PlayerChar.z) % TileSize-1;

(TS is a var containing the size of a minimap tile, TileSize holds the size of a dungeon tile)

I even tried

offsetx = abs(PlayerChar.x / TS) % TS-1;
offsety = abs(PlayerChar.z / TS) % TS-1;

which actually came close but no cigar. I have natch tried them all without the -1 too. and I have tried both adding the offset and subtracting the offset from the tile locations.

Tiles are calculated as:

DrawX = dx + ((tx - 1) * TS) - offsetx;
DrawY = dy + (y * TS) - offsety;

without the offsets its a perfect adverage tile renderer that scrolls 1 tile at a time, with offset it goes all over the place :/

what have i forgotten/missed?

Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 3rd Sep 2005 14:42
fixed it in a flash of inspiration, the nessiariy calculation was:

offsetx = (abs(PlayerChar.x) % TileSize) / TS;
offsety = (abs(PlayerChar.z) % TileSize) / TS;

took into account the length of a real dungeon tile but clamped it to the size of a minimap tile ^^

Login to post a reply

Server time is: 2024-11-19 01:19:30
Your offset time is: 2024-11-19 01:19:30