Small maps and clipping
I''ve been banging my head against the wall for three days... help?
I''m working on an iso engine, 64*32 in C and C++. The problem I have is when I render a small map, say 10*10, I get the full map, tiled across the screen several times (e.g. the map wraps and the whole map appears on screen a few times...) I used Isometrix and Jim Adam''s tutorial as a guideline for my basic engine, and I think the problem is somewhere in all the screen wrapping stuff they use. Can anyone shed some light on the whole map wrapping and redundant tile elimination algorithm?
if this is the map:
a /\ b
/ \
/ \
\ /
c \ / d
\/
how do I keep from drawing my tiles in areas a,b,c,and d?
Thanks in advance.
Tim
Fingh@hotmail.com
Okay, so the editor doesn''t like preformatted spaces...
space the line drawing in the above post so it looks like a diamond. I basically need to know how to NOT blit tiles that are outside of the map.
thanks again.
space the line drawing in the above post so it looks like a diamond. I basically need to know how to NOT blit tiles that are outside of the map.
thanks again.
you mean like:
Like that? You want a b c and d to be black or not painted... well I''m not sure how everyone else does it, but in my game each tiles is represented by a 16 bit number. 0 or NULL being that it doesn''t get painted... this way I can make the map any shape I want by putting in null tiles... that''s my easy solution, I used it mainly because I can also have odd shaped levels that look like provinces or states...
See ya,
Ben
a /\ b / \ / \/ \\ / \ / \ /c \/ d
Like that? You want a b c and d to be black or not painted... well I''m not sure how everyone else does it, but in my game each tiles is represented by a 16 bit number. 0 or NULL being that it doesn''t get painted... this way I can make the map any shape I want by putting in null tiles... that''s my easy solution, I used it mainly because I can also have odd shaped levels that look like provinces or states...
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
An easier way is to draw the tiles in the following format:
this way you can remove a lot of the problems with movement, i.e. if you wanted to move nort east then just take 1 off of the y co-ord.
This way also allows you to remove a lot of the blank tiles, so that the map has a smaller memory requriement.
The rules for drawing the map this way is still the same as for the civ type maps, but just remember to draw the tiles like above, i.e. itterate allong the x axis of your map and draw them south east.
the following pseudo code will produce the map.
I think it''s correct, you may need to play around with the xpos and ypos a bit. It''s been over 5 years since I wrote this algorithm, well before I actually had access to the internet, and all of the new information about Iso maps.
If you need any additional help you can e-mail me if you want
1 5 2 9 6 3 13 10 7 4 14 11 8 15 12 16
this way you can remove a lot of the problems with movement, i.e. if you wanted to move nort east then just take 1 off of the y co-ord.
This way also allows you to remove a lot of the blank tiles, so that the map has a smaller memory requriement.
The rules for drawing the map this way is still the same as for the civ type maps, but just remember to draw the tiles like above, i.e. itterate allong the x axis of your map and draw them south east.
the following pseudo code will produce the map.
init map[MapWidth][MapHeight]for y = 0 to MapHeight for x = 0 to MapWidth xpos = ( x * ( TileWidth / 2 ) ) - ( y * ( TileWidth / 2 ) ) ypos = ( y * ( TileHeight / 2 ) ) + ( x * ( TileHeight / 2 ) ) Blit tile map[x][y] at xpos + xoffset, ypos + yoffset nextnext
I think it''s correct, you may need to play around with the xpos and ypos a bit. It''s been over 5 years since I wrote this algorithm, well before I actually had access to the internet, and all of the new information about Iso maps.
If you need any additional help you can e-mail me if you want
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement