#### Archived

This topic is now archived and is closed to further replies.

# scrolling isometric tilemap

This topic is 6931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i looked through all of the tutorials on the resource page...none of them have anything about scrolling isometric tilemaps. one had an explination that was basicly like "you load all of your tiles into memory and then when the player moves you shift the visible bits on the screen" well, duh. but it gave no code examples. i''m not asking somone to write all of the code for me, but how am i supposed to learn without viewing at other peoples code? so, if anyone knows anything about scrolling maps then reply please. if you need to see my current code i will email it to you. thanks

##### Share on other sites
someone please reply, ive spent the last 3 hours trying to figure this out. i dont just need the math part of the code, i need the directx draw part of the code too, the part that actually MOVES the tiles. i''m stumped

##### Share on other sites
Well, I'm no professional iso/hex programmer. I did make a small dx tile scrolling map once, though.

Anyways, the way I'd do it is I'd have two classes:
1. The Map class (previously explained in every iso/hex article)
2. The Screen class (or Camera or whatever you want to call it)

Basically, the map stores what's in each tile:
Map {
Tile[d1][d2] m_aaTiles;

void draw(Screen *);
}

the Screen maintains where the viewer is:

Screen {
int minx, miny, maxx, maxy;
int curx, cury, width, height;

void scroll(direction);
};

Then in the scroll function you would increment the curx or cury, depending on the direction, and if curx + width > maxx you set curx = maxx - width; and if curx < minx you set it to minx. (do same thing for y's, but with height)

Then in the draw function, find the current up-left tile (based off where curx is), and loop through cury to cury+height with curx to curx+width tiles in it.

The thing you have to account for is incremental pixels (so you are scrolling smoothly, instead of a tile at a time).

You can do this by offsets with a tile, and/or refernce the Screen based off of total world pixels, and have it convert to tile position.

Hope this helps.

-edited it since the array code was not shown correctly

Dark Lord Pi

Edited by - Lord Pi on 4/30/00 4:52:12 PM

##### Share on other sites
i dont get that at all. i mean, i understand it, but i dont know where to go from the code you gave me. im totally confused about this. does anybody have a example program like this but with source?

##### Share on other sites
maybe i can help u...

because i work at a RTS game and i use a lot o tiles

i dont know it they are iso...

I programm in ASM but i think u want C..?

Maybe i can explain it to you and u code it in C?

Best of luck
Bogdan

obysoft

##### Share on other sites
It''s just a basic part of any kind of scrolling system. You need a variable or 2 to store the camera''s location within world space. To get a screen location from a world location, subtract the camera position. To get a world location from an on-screen position, add the camera''s position. You would generally centre the view on a character, in my case done by setting viewX and viewY to the character''s world position minus half the screen size.

##### Share on other sites
Kinda ironic with your name being ''gameprogrammerwiz''. Hehe. Sorry, couldn''t help myself.

##### Share on other sites
>i''ve spent the last 3 hours trying to figure this out

That''s part of your problem. You spent 3 hours, well it took me a week+ to figure out how to make a ismetric scrolling engine, and it''s still buggy as hell. No one is going to give you code the''ve spent that kind of work on, just spend time on it, you''ll figure it out -- since your a game programming wiz and all.

##### Share on other sites
ok, lets clear up my name...i can never think of good handles/names i picked the one that i would hope to be someday. if you wish for something it usually happens. of course, its also usually winter in hell when i wish for things.

ok, i fully understand the camera/map cord system. what i DONT know is how to shift my tiles, i have no idea how to just move tiles (images in general) around. if i could just figure that out, then i could prove to you guys that there is some truth to my name.

##### Share on other sites
Well, to "move" your tiles or to make them appear to move, you''d have to create a function that draws, say, 16 tiles by 16 tiles depending on the world camera for the whole map.

Suppose you have a 32*32 tile map, but you can only display 16*16 at a time on the screen, so you''d create a variable called world_camera or something, to track where you are in the world and which tiles to draw.

For the time being, let''s forget about scrolling. Do you know how to display tiles from a map on the screen? Make sure you get around to that part first.

BTW, I''m writing an article on doing tile-based games (maybe scrolling) in DirectX, so you can check it out when I''m done. I don''t know when though

Sorry if I sounded a little tense...I''m just bummed about not being able to enter the contest. I mean, I had a fully playable game but I felt that it could be so much better before I release it. Oh well.

Good luck, and if you have any questions, post em.

Martin

• 15
• 13
• 35
• 39