Steven

Members

271

136 Neutral

• Rank
Member
1. Rotated vs staggered isometric tile selection

Have you looked at the iso article on here that I wrote? http://www.gamedev.net/reference/articles/article2026.asp That article deals with adding height to your diamond / rotated maps, but it has all the code in there to help you work out your mouse maps.

3. random iso map

Quote:Original post by web_scripter Um there's something wrong with the code. there are two if statements that are the same but contain different code. else if ( ( x == 0 ) && ( y > 0 ) ) map[y][x] = map[y-1][x] + ( ( rand() * 3 ) - 1 ); else if ( ( x == 0 ) && ( y > 0 ) ) map[y][x] = map[y][x-1] + ( ( rand() * 3 ) - 1 ); Well I did say it was from memory :D The correct lines should be: else if ( ( x == 0 ) && ( y > 0 ) ) map[y][x] = map[y-1][x] + ( ( rand() * 3 ) - 1 ); else if ( ( x > 0 ) && ( y == 0 ) ) map[y][x] = map[y][x-1] + ( ( rand() * 3 ) - 1 );
4. random iso map

C# - Urg I'm not touching that with a barge pole - well not for a while at least :D I've been trying to find an old article I read about a simple random terrain generator, but alas I can not, so this is from memory. This is in C using the rand() functiona... for( x = 0; x < 6; x ++ ) { for( y = 0; y < 6; y ++ ) { if( ( x == 0 ) && ( y == 0 ) ) /* First pos, pick a random height */ map[y][x] = rand() * 5; else if ( ( x == 0 ) && ( y > 0 ) ) map[y][x] = map[y-1][x] + ( ( rand() * 3 ) - 1 ); else if ( ( x == 0 ) && ( y > 0 ) ) map[y][x] = map[y][x-1] + ( ( rand() * 3 ) - 1 ); else map[y][x] = ( ( map[y-1][x] + map[y][x-1] ) / 2 ) + ( ( rand() * 3 ) - 1 ); } } Of couse you will have to put in some checks to make sre that the height that has just been done does not break the rules of your tile set, but that code can produce some interesting maps with the right seed for the random number generator. Doesn't C# use Direct8+ which means your working in DirectGrpahics, if that's the case then I'd sugest forgetting about the tileset, and making the engine use the hieghts that you are generating with your terrrain generator it would look better, and you can change the rand() * 3 - 1 to something like rand() * 5 - 2, which would give you a more random map...
5. random iso map

Are they the tiles I supplied in my article? If not, why do you have a hole for tile 16? Anyway... How I'd did it was to create a 6x6 grid and do the usual random height generator, making sre you only change the height by one along the X / Y axis... the 6x6 grid for your test map is (ignore the X rows for now): 0 0 1 1 0 0 X X X X X 0 0 1 1 0 0 X X X X X 0 0 1 1 0 0 X X X X X 0 1 1 1 1 1 X X X X X 0 1 1 1 1 1 X X X X X 0 1 1 0 1 1 Now to convert this into the 5x5 map take the 4 values around an X and assign these to a bit field: 8 4 2 1 BL BR TR TL Making sure that the values you put in are the diference between the lowest height for that 4 and the corner your looking at. Once you put these values into a bitfield, you will have the tile you need. If there is a case where the height between the lowest and highest point is 2 then you use the special tiles at the end of that tile set you pasted. First row conversion: 0 0 0 0 = Tile 0 or a flat tile ( 1 1 1 1 = tile 0 as well ) 0 1 1 0 = Tile 6 or the slope up at the bottom right 1 1 1 1 = Tile 0 as the lowest point is also the same height as the rest of the tile 1 0 0 1 = Tile 9 or slope down from top right 0 0 0 0 = Tile 0 or a flat tile ( 1 1 1 1 = tile 0 as well ) Nice and easy 2 stage process... Of course you could add a further tileset for water - ground (basically all the edges at height 0 have some sand on them, and the flat tile is blue) or a rocky set (brown tiles) and finally a white set for snow.
6. converting 2D tile map to ISO tile map

Quote:Original post by Wyrframe Just reducing Tile_width to 63 from 64 ought to do it. You really want odd-width, odd-height tiles, anyway; preserves perspective and shape better in practise. As it is, if those tiles are even-width, you'll get some overlap, but it will prevent those seams. I've never had any overlap with those tiles, as they are 64 width and 31 height. Also they are the same size as TANSTAAFL uses in his book (smallest tile you can make is 1x4 for software rendering) Edit: void draw_tiles(void) { for(Tileset.y=0; Tileset.y <Mapy;Tileset.y++) { for(Tileset.x=0; Tileset.x < Mapx; Tileset.x++) { //what does this do? Tileset.scroll_x = Tileset.x + ( Tileset.world_camerax / Tileset.Tile_Width );//this allows scrolling on y axis Tileset.scroll_y = Tileset.y + ( Tileset.world_cameray / Tileset.Tile_Hight );//this allows scrolling on x axis Tileset.offset_x = Tileset.world_camerax + ( screenx / 2 ); Tileset.offset_y = Tileset.world_cameray + ( screeny / 2 ); Tileset.tiles = map[ Tileset.y ][ Tileset.x ]; tile_src.left = ( ( Tileset.tiles ) % 20 ) * Tileset.Tile_Width; tile_src.top = ( ( Tileset.tiles ) / 20 ) * Tileset.Tile_Hight; tile_src.right = tile_src.left + Tileset.Tile_Width; tile_src.bottom = tile_src.top + Tileset.Tile_Hight; dstr.left = ( ( Tileset.x - Tileset.y ) * Tileset.Tile_Width / 2 ) + Tileset.offset_x; dstr.right = dstr.left + Tileset.Tile_Width; dstr.top = ( ( Tileset.y + Tileset.x ) * Tileset.Tile_Hight / 4 ) - Tileset.offset_y; dstr.bottom = dstr.top + Tileset.Tile_Hight; lpBackBuffer->Blt(&dstr,g_pddTile,&tile_src,DDBLT_WAIT|DDBLT_KEYSRC,NULL); } } } I fixed a couple of errors in your code, the main one was to do with you shrinking the tile in the vertical axis by half, and posibly putting 2 tiles on the screen in one go. The other error I spotted was to do with getting the Y locations you were using half the tile height, but your tile height was 4 times the size it should actually be, so fixing those 2 errors you should have all the tiles sitting snuggly next to each other. [Edited by - Steven on May 24, 2005 12:38:28 PM]

8. converting 2D tile map to ISO tile map

I use this: void clear( DWORD Colour ) { DDBLTFX ddfx; DXSTRUCTINIT( ddfx ); ddfx.dwFillColor = Colour; lpBackBuffer->Blt( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddfx ); }
9. converting 2D tile map to ISO tile map

Simple answer to your 'ghosting' problem would be to clear your back buffer before you start to draw the next screen. For the height maps and the scrolling look at my article here it uses 2:1 diamond tiles, not 1:1 tiles that you are using. The other 2 things you are working on is down to your drawing loop, so once you get the drawing sorted, the other two (animation and layers) will fall into place very easily.
10. converting 2D tile map to ISO tile map

Could you post a screen shot of how the times are being drawn to the screen? this might help us determine exactly what's happening. Your doing everything correctly as far as I can see, but without a pic of what your getting then I'm unable to help determine the exact problem. Also as for the clipper, I never use it, I don't think I've ever used a clipper on DirectDraw (just checked my game engine that I'm working on now, and the clipper code is all commented out). You can get away with manual clipping of the image, it's a little harder to do initially, but once you work it out it's very easy to do, this also means you can do custom clipping rects without having to ploay around with the clipper. If your base / land layer uses iso tiles that are 32x16 (stored in a 32x32 size tile) then your second / object layers can be any height and width, BUT you are better off kepping your width to 32, and splitting up larger objects into multiple objects.
11. Help with Mouse coordinates

Quote:Original post by Rozik This is my code for the mouse location: the x position is right and at the top of the map the y position is right too but at the lower map tiles the y coordinate is off case WM_MOUSEMOVE: { x = (int)LOWORD(lparam); y = (int)HIWORD(lparam); tile[RegionX][RegionY]->next=NULL; RegionX=int(x/40) ; RegionY=int((y/21)*2); int MouseMapX=x % 40; int MouseMapY=y % 21; HDC hdc; MouseMap->name->GetDC(&hdc); COLORREF ERG= GetPixel(hdc,MouseMapX,MouseMapY); red = GetRValue(ERG); green = GetGValue(ERG); blue = GetBValue(ERG); if(red==255 & green==255 & blue==255){ } if(red==255 & green==0 & blue==0){ RegionX-=1; RegionY-=1; } if(red==0 & green==255 & blue==0){ RegionX-=1; RegionY+=1; } if(red==0 & green==0 & blue==255){ RegionY+=1; } if(red==255 & green==255 & blue==0){ RegionY-=1; } MouseMap->name->ReleaseDC(hdc); if(RegionX<0) RegionX=0; if(RegionX>24) RegionX=24; if(RegionY<0) RegionY=0; if(RegionY>64) RegionY=64; tile[RegionX][RegionY]->next=new Image(lpddsback,Marker); tile[RegionX][RegionY]->next->SetXpos(tile[RegionX][RegionY]->GetXpos()); tile[RegionX][RegionY]->next->SetYpos(tile[RegionX][RegionY]->GetYpos()); // change=TRUE; return(0); } If your coding this in C++ then there is a few problems with your code allocating and de-allocating memory (read this as huge memory leaks), if it's Java ... then you might be doing it right, but IIRC java does not do pointers, or GDI. This section of code: COLORREF ERG= GetPixel(hdc,MouseMapX,MouseMapY); red = GetRValue(ERG); green = GetGValue(ERG); blue = GetBValue(ERG); if(red==255 & green==255 & blue==255){ } if(red==255 & green==0 & blue==0){ RegionX-=1; RegionY-=1; } if(red==0 & green==255 & blue==0){ RegionX-=1; RegionY+=1; } if(red==0 & green==0 & blue==255){ RegionY+=1; } if(red==255 & green==255 & blue==0){ RegionY-=1; } can be changed to a switch: COLORREF ERG= GetPixel(hdc,MouseMapX,MouseMapY); switch( erg ) { case RGB(255,0,0): RegionX-=1; RegionY-=1; break; case RGB(0,255,0): RegionX-=1; RegionY+=1; break; case RGB(0,0,255): RegionY+=1; break; case RGB(255,255,0): RegionY-=1; break; case RGB(255,255,255): //do nothing; break; } Also I'm hoping that the if statements are incorrectly copied as: if( red == 255 & green == 255 & blue == 255 ) means, brackets used to empisize the way the code is looked at if red == ( 255 and green == ( 255 and blue == 255 ) ) what you want is: if ( ( red == 255 ) && ( green == 255 ) && ( blue == 255 ) ) Another good article on mouse maps (and I allow height in my iso maps) http://www.gamedev.net/reference/articles/article2026.asp If your getting TANSTAAFL's Iso book, then the code in my article above is based on his code from his book, which in turn is based on the article you first linked to ( which is also his ) If you have any queries about my article I've changed ISP and my e-mail is now sharriso AT nildram DOT com ( do the normal replace information as I was getting a lot of spam mail on my old accout by handing out my e-mail in forums )
12. Tile-based movement using Time-based movement

Your first method should work fine, and the reason your moving off the map is down to your keyboard decoding setion, this is me running though the code by hand, so I might be out a little. if you hit all 4 directions at one the following will happen: Current DestX/Y = 100,100 Update(); DestX = 100 DestY = 100 state = 4 Which means that it's going left, and the line: if (x - speed * FPS.Instance.FrameTime < destX) will always be true, unless speed = 0; Now onto what I would sugest: you know how long it would take the unit to move 1 tile, lets make this 1 tile (32x32) in 8 seconds (easy maths), or 4 pixels / second or 0.004 pixels / 1 millisecs which is at a scale we can use with the FPS counter, so we know that we can safely use this speed variable to move, BUT with pc's being what they are, you will end up with a nice problem of over or under arriving, this is sorted by adding a dest value and testing against this, this way you will not only get a nice smooth movement but also a static STOP at the end. Or in otherwords use both your methods, but fix the code to grab your keyboard input as the way it is now, does not help you with silly people hitting all 4 direction keys at once.