How to scroll a tile map (C# with Directx)

Started by
1 comment, last by MarkS_ 11 years, 6 months ago
Please, give me a example about scrolling tile map or some tutorial.
thanks!
Advertisement
[EDIT: Holy crap, I said that backwards. That's what I get for having Beef Jerky and Monster for breakfast...]

Tilemaps can be done in many ways, so I'll keep this as general as possible: When tiles are initially positioned, a simple Vector2 can be subtracted from the tile's drawing position, and in effect making the map scroll. By repositioning the tile's drawing position instead of the base location, any collision math you have can be preserved. If your particular programming language doesn't support Vector2 objects, just use X and Y values.

"Only idiots quote themselves" - MisterFuzzy

I haven't used DirectX for this, but I have used OpenGL which is similar. Don't scroll the tile map geometry. Send the entire tile map geometry to the GPU once. From there on out, translate your modelview matrix to scroll the map. Only resend the geometry if it changes.

[edit]
I wrote the original post in haste. Edited for clarity.

This topic is closed to new replies.

Advertisement