Skip to main content
GameDev.net gamedev.net
🔒 Locked

Tiling in direct3d with rectangles

Started by abcdefg Apr 22, 2005 at 10:02 PM 2 replies 1k views
Original Post
abcdefg
abcdefg
Okay I made a few changes to my program, but it still doesnt work. I was just wondering if maybe someone else had a similiar tile engine and could maybe spot a problem with my code. The tiles move one tile at a time, but not smoothly. Anyone see anything wrong?

for(int y=0;y<numtilesy+1;y++)
	{
		for(int x=0;x<numtilesx+1;x++)
		{
			//mapspritedraw();

			int scrollx=worldx/tiledimx;
			int scrolly=worldy/tiledimy;

			offsety=scrolly % tiledimy;
			offsetx=scrollx % tiledimx;

			tilecoord.x=(x*tiledimx)-offsetx;
			tilecoord.y=(y*tiledimy)-offsety;

			TileLookUp(97,32,32,map[scrolly+y][scrollx+x],rect);
			mapsprite.Draw(anobject->pTexture,▭,NULL, NULL, 0.0f,&tilecoord,0xffffffff);
		}
	}

eal
eal
I think instead of:

offsety = scrolly%tiledimy;
offsetx = scrollx%tiledimx;

try this:

offsety = worldy%tiledimy;
offsetx = worldx%tiledimx;
abcdefg
abcdefg
I tried your suggestions and for some reason its still not scrolling. Its hard to think through how all the tiles are being effected each frame. For something seemingly so simple its actually pretty hard.
eal
eal
Do you think you could post more of your source? It scrolled fine for me when I adopted it to work with a program I made a while ago.

[Edited by - eal on April 24, 2005 12:04:03 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.