Sign in to follow this  

[Solved] Rendering a Tiled Game using a Custom Texture2D

Recommended Posts

Hi, a quick performance Question here. I am current working on a tile engine which is drawn using a int[,] and foreach tile I draw a Texture in a rectangle using
t_bgTexture = new Texture2D(deviceRef, 1, 1, 1, TextureUsage.None,          SurfaceFormat.Color);
t_bgTexture.SetData<Color>(new Color[] { c_tilebgColor });
my Question. Is Drawing these custom textures every time I draw going to cause latency(lag) in my game? Currently I am using a cameraPosition Vector to control movement and simply subtract the current cameraPosition from each tile when it is drawn. And for some reason it is extremely jumpy, as in not smooth scrolling. I have used this method before and it worked fine, the only thing that I can see is different is that last time I was using Textures loaded from a file. N.B I have an array 23x23 and each tile is 2 textures 23^2 = 529 * 2 = 1058 ... therefore 1058 Textures being Drawn all of different Colors. (sory i cant be more specific .. rushing off to bed gotta be up in 4 hours :S) [Edited by - Andy474 on September 14, 2009 2:55:59 PM]

Share this post

Link to post
Share on other sites
Solved ::

It turns out I was actually adding a tile to a List every time I rendered it ... therefore Basic maths :

1058 tiles per Draw
6 draws per second

1058 * 6 = 6348 tiles being added to the list per second ... and 380,880 per min

so no-wonder I was experiencing massive performance issues :P

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this