// mWidth, mHeight <- Integer sizes of the map
// tSize <- the size of a tile (I assume they are square)
// sprman[map[y][x].sprite_id] <- a graphic pointer
void blitSquare(const int nx, const int ny)
{
int yoffset = tSize/2 - (tSize/4);
for (int y = ny; y < mHeight && y < screen->height() / (tSize/2); y++)
{
for (int x = nx; x < mWidth && x < screen->width() / tSize; x++)
{
Point p;
p.x = x * tSize + (y & 1)*(tSize/2);
p.y = y * (tSize/4 + 1) - yoffset;
screen->blit(p, sprman[map[y][x].sprite_id]);
}
}
}
// scrolling the diamond shape is severly broken.
// it only draws portions of the map, not even diamond shaped
void blitDiamond(const int nx, const int ny)
{
Point pt;
int w = 0,
x = nx,
y = ny,
z = 0;
int yoffset = 0;
for (y = ny; y < (mHeight-ny); z = ++y)
{
for (x = nx; x <= y; x++)
{
pt.x = screen->width() / 2 + (((x*2)-y) * tSize/2);
pt.y = (yoffset * tSize/4);
screen->blit(pt, sprman[map[z--][x].sprite_id]);
}
yoffset++;
}
for (z = --y; z >= nx; z--)
{
w = y;
for (x = (mWidth-z); x < (mWidth-ny); x++)
{
pt.x = screen->width() / 2 + ((((x*2)-y)-((y+1)-z)) * tSize/2);
pt.y = (yoffset * tSize/4);
screen->blit(pt, sprman[map[w--][x].sprite_id]);
}
yoffset++;
}
}
Thanks all! Hopefully, I''ll get a chance to help someone out with this in the future
random
---
Wait, you mean I have to actually... THINK?!
Need advice: Isometric map as square/diamond? (Code included)
Hi,
I have been working on my iso map for... err... a day now I see that there are two different ways to display a map to the screen. The entire map looks like a tile (huge diamond) or a square map with diamond tiles.
To make it clearer, I''m not talking about the tiles, just how the map itself is drawn to the screen.
My question is, which is "preferable" and why? I''ve done tons and tons of flat maps, but this is my first iso map. I''ve got both the diamond display shape working and the square shape.
The diamond shape seems to be a tad faster (umm... dunno), but navigating/scrolling/pathing seems like it would be a total nightmare. I do like the way the world just sort of "ends" though. Very nice for small maps!
The square shape is cool, not tons of vacant area on the screen. It would also seem to navigate better. Having a small map would rather suck though, the map would end and be very jagged on the ends. I am talking maps like 20x40 where they don''t even fill the entire screen.
Anyways, here''s the code I''m using now. If anyone has any suggestions, I''d be Very grateful!
---Wait, you mean I have to actually... THINK?!
Here''s a clearer and cleaner version of the blitDiamond() function. Just a side note, it doesn''t use the arguments yet, I was just trying to get it to display right...
Thanks!
random
---
Wait, you mean I have to actually... THINK?!
void blitDiamond(const int nx, const int ny){ int z = 0; int x = 0; int y = 0; int xoffset = 0; int yoffset = 0; for (z = 0; z < mHeight; z++) { x = 0; y = z; xoffset = (mWidth-z) * tSize/2; while (x <= z) { Point p = {xoffset,yoffset}; screen->blit(p, sprman[map[y][x].sprite_id]); xoffset += tSize; x++; y--; } yoffset += (tSize/4)+2; } while (--z) { x = mWidth - z; y = mHeight - 1; xoffset = (1+mWidth-z) * tSize/2; while (x < mWidth) { Point p = {xoffset,yoffset}; screen->blit(p, sprman[map[y][x].sprite_id]); xoffset += tSize; x++; y--; } yoffset += (tSize/4)+2; }}
Thanks!
random
---
Wait, you mean I have to actually... THINK?!
---Wait, you mean I have to actually... THINK?!
the choice of the diamond map or the staggered map is mainly personal preference. Civ II, Imperialism II, Civ: CTP, Alpha Centauri all use the staggered style (the square map with iso tiles)
Sim City, AoE, Caesar II and III, etc use the diamond map.
Generally speaking, the staggered map is used when the entire viewing area is going to be filled up most of the time, usually for worlds that wrap around east to west, and diamond map are for the "flat earth" look, where there is no wrapping.
Personally, i really like the diamond shaped map. yes, there are huge black areas, but the edges to those areas are in a nice straight line, so the entire map looks like one big iso tile.
Sim City, AoE, Caesar II and III, etc use the diamond map.
Generally speaking, the staggered map is used when the entire viewing area is going to be filled up most of the time, usually for worlds that wrap around east to west, and diamond map are for the "flat earth" look, where there is no wrapping.
Personally, i really like the diamond shaped map. yes, there are huge black areas, but the edges to those areas are in a nice straight line, so the entire map looks like one big iso tile.
Get off my lawn!
Thanks for the response,
I rather like the diamond shape too, but being that it''s a top down world style game I think I''ll be relegated to doing the square. I have always wanted to put the map crossover to the other side of the world. IMHO, that would look really odd on a diamond board. Ah well...
On the bright side, there are always more games to write! Besides, writing an engine that could do both is a challenge I look forward to.
Oh, the reason the diamond was faster had nothing to do with the code... the diamond draws less tiles to the screen. I rather missed that fact earlier (it''s been a long day...)
Thanks TANS!
random
---
Wait, you mean I have to actually... THINK?!
I rather like the diamond shape too, but being that it''s a top down world style game I think I''ll be relegated to doing the square. I have always wanted to put the map crossover to the other side of the world. IMHO, that would look really odd on a diamond board. Ah well...
On the bright side, there are always more games to write! Besides, writing an engine that could do both is a challenge I look forward to.
Oh, the reason the diamond was faster had nothing to do with the code... the diamond draws less tiles to the screen. I rather missed that fact earlier (it''s been a long day...)
Thanks TANS!
random
---
Wait, you mean I have to actually... THINK?!
---Wait, you mean I have to actually... THINK?!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement