Jump to content
  • Advertisement
Sign in to follow this  

Tilemap, smooth scrolling

This topic is 4590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I understand that you're probably tired of this question ^__^ but here it goes, How can i make my maprender-function as smooth as possible? I'm using direct3d in c#. My tiles are positiontextured quads and they all share the same vertexbuffer. (may be bad?) anyway, this is how i render the map:

if(System.Environment.TickCount - lastFrame >= 10) 
	lastFrame = System.Environment.TickCount;
Camera.Teleport(xScroll,yScroll,0); //translates the viewpoint   

for(int m = 0; m<MAPXSIZE; m++)
	for(int n = 0; n<MAPYSIZE; n++)
		if(tiles[m,n].Visible)		//draw if it's visible
			device.SetStreamSource( 0, tile.VertexBuffer_, 0);
			device.VertexFormat = CustomVertex.PositionTextured.Format;

			QuadMatrix.Translate(-1f+tiles[m,n].XPos,(1f-tiles[m,n].YPos), 0); //in screen-coordinates
			device.SetTransform(TransformType.World, QuadMatrix);

			device.RenderState.AlphaBlendEnable = true;
			device.RenderState.AlphaTestEnable = true;
			device.RenderState.ReferenceAlpha = cK.ToArgb(); //colorkey for transparency
			device.RenderState.AlphaFunction = Compare.Equal;

			device.SetTexture(0, tile.tileTextures[tiles[m,n].TextureTypeX,tiles[m,n].TileTextureY]); //setting the right texture
			device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);

So, I thought it would be the best to just lock the input so the other things can run as fast as it can. But it doesn't seem to make any differnce.. this is how i update the camerapositions with the keyboard.
private void UpdateInput()  
	DXInput.KeyboardState keys = inputDevice.GetCurrentKeyboardState();   
	if (keys[DXInput.Key.LeftArrow])


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!