Advertisement

Tile overlap/ correct position problem

Started by January 05, 2001 09:18 PM
5 comments, last by Zeke 24 years ago
I have a tile engine coded, however no matter what i do i cannot get it to fit tiles properly. I have tried 2 ways the latter being from tanstaafl''s tutorial: the tiles are 48*23 I have calculated the X and Y overlap by actually looking at the tiles in photoshop and putting them together to find the overlaps (if that makes any sense- i followed the tutorial for this but my tiles are a different size to the ones in the tutorial so that might be why it doesnt work)
  
int x, y, X_Overlap=24, Y_Overlap=12, PlotX, PlotY;
for(y = -1; y <= MAP_Y; y++)
{
   for(x = -1; x <= MAP_X; x++)
   {
	PlotX = x+2*X_Overlap*x+(X_Overlap)*(y&1);
	PlotY= y+Y_Overlap*y;

	if (!BackSurface.Draw(PlotX, PlotY, TILE_WIDTH,
                         TILE_HEIGHT, 0, 360, lpddsStuff, 1))
	{
					
        MessageBox(main_window_handle, "Draw Surface", NULL,0);
	return 0;
	}
			

  
Map_X is Screen_Width (800) / Tile_Width +1 Map_Y is ScreenHeight (600) /Tile_Height +1 This is fine for filling the screen however it leaves a few pixels uncovered and nothing i can do short of completely overlapping tiles (which leaves blank screen near the bottom or at the right) will correct it. If anyone can understand what I am trying to say and can help i would be most appreciative. Thanks for your time Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
It''s a two dimensional rotation problem specific to how your tiles look. Unless I had a fullsize picture of a tile I couldn''t help you completely.

Basically it''s

ScreenY=MapY*32+MapX*16
ScreenX=MapX*48-MapY*24

I''m not sure if there is a page out there explaining how the four numbers used are caclulated but there may be. I figured it out by trial and error initially and then found the formula. Any size tile works provided it''s a diamond or offset square. I''m forgetting my math terms here.

Ben
Advertisement
Thanks for the reply but I figured out the problem. It isnt the values that are wrong its that somewhere in my program the bitmap to be displayed loses its first row and first column of pixels. I have looked everywhere for something that can be causing this but I cant find it. I think it might be to do with the bitmap loading function (im using the one out ot TOTWGPG) but Im at a loss.

If anyone can help Id be very greatful

Thanks for your time

Just my thoughts take them as you will.

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
If the blt-function you are refering to takes width and height then I suspect you have computed the width and height wrong. If it takes a bounding box from your tile, you should increase its size.
Post the function prototype and the dimensions of the bitmap. The actual bitmap would be helpful too.


Later,
Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

TOTWGPG uses the BOB engine (eyckk.. what a mistake that was trying to program for it)

Anyway, Andre uses 0,0 as his starting point for loading the bitmaps, unfortunatly, he loads everything >0,0 so the first row/column never loads

In the Load_Bitmap_File function, you can try to use -1,-1 as your starting point.

--LordKaT
Th function prototype for blitting the bitmaps is:

int Surface::Draw(int x, int y, int cx, int cy, int sx, int sy, Surface &source, int transparent)

x, y are the coords to blit to on the backbuffer.
cx,cy are the height and width of the bitmap
sx and sy are where on the bitmap the actual image starts (i.e. where is the actual tile on the bitmap if the bitmap is a collection of tiles)

The function then goes on to create source/dest rects:

dest_rect.left = x;
dest_rect.top = y;
dest_rect.right = x+cx-1;
dest_rect.bottom = y+cy-1;

source_rect.left = sx;
source_rect.top = sy;
source_rect.right = sx+cx-1;
source_rect.bottom = sy+cy-1;

and then goes on to blit:

if (FAILED(lpdds->Blt(&dest_rect, source.lpdds,
&source_rect,(DDBLT_WAIT | DDBLT_KEYSRC),
NULL)))
return 0;

The actual size of the bitmap makes no difference as whatever the size it always misses the first row and first column. The actual tiles are 48x23 from a 640x480 tileset. I have calculated the dest and source rects numerous times and I have been messing with the values aswell (i.e. trying sx-1,sy-1 etc)

KalvinB> I cant find anywhere in the Load_Bitmap_File that takes any integers to start loading from so i cant find where to use use -1,-1 as the starting point to load from. The code uses
_lseek(file_handle,-(int)bitmapinfoheader.biSizeImage),SEEK_END);
_lread(file_handle,buffer,bitmapinfoheader.biSizeImage);


Thanks for the help guys I''m going crazy with this problem


Just my thoughts take them as you will.

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Advertisement
Ive figured it out now. Thanks for the help

Just my thoughts take them as you will.

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

This topic is closed to new replies.

Advertisement