h1

XNA Performance on the Xbox360

August 23, 2011

well , we’ve started working on a C# XNA game couple of days ago , the plan was to first finish working on the game on the pc , then after that , to port the game to the Xbox360.
but now as i was browsing the web , it seems that porting it to the 360 will be really..really tough !
i mean , it seems that XNA runs way slower than pc , and obviously way slower than native code on the same console
i guess finding this out before actually starting to get deep in code means I’ve saved my self much more optimizing , but I just hate the fact that I’ll have to worry about each part of my code and see if it effects the performance at all , i mean even if the loop is delayed by 1 second , it’s going to cause problems.
but seriously microsoft ! it’s just a 2D Shooter game , and i thought developers never had to worry about 2D games performance ever since the SNES !
this article here had very interesting tips :
http://www.krissteele.net/blogdetails.aspx?id=140
virtual functi–(oops , sorry i meant methods , I’m a bit used to the C++ name =P )
anyway , it seems that virtual methods are 40% slower than static/instance method..from that alone i can see the changes i have to make on my code =/
wow..and it seems I’ll have to code the entire enemy code in one class *sigh*
and i guess then that i’ll have to get rid of my pixel-sliding code >.> ..or at least will try to optimize it more !
now that i take a fast look , it seems that i was very generous with the method , don’t blame me..I’ve never had to actually WORRY about my 2D game performance before
static public Vector2 getSlideVector(Rectangle rectangleA, Color[] dataA,
Rectangle rectangleB, Color[] dataB, float speed)
{

int top = Math.Max(rectangleA.Top, rectangleB.Top);
int bottom = Math.Min(rectangleA.Bottom, rectangleB.Bottom);
int left = Math.Max(rectangleA.Left, rectangleB.Left);
int right = Math.Min(rectangleA.Right, rectangleB.Right);
for (int y = top; y < bottom; y++)
{
for (int x = left; x < right; x++)
{

Color colorA = dataA[(x - rectangleA.Left) +
(y - rectangleA.Top) * rectangleA.Width];
Color colorB = dataB[(x - rectangleB.Left) +
(y - rectangleB.Top) * rectangleB.Width];

if (colorA.A != 0 && colorB.A != 0)
{

return new Vector2(rectangleA.X, y - rectangleA.Height+1);

}
}
}
return new Vector2(rectangleA.X,rectangleA.Y);
}

well..*sigh* not very much to add =/ , but it seems I’ll have to work hard from now and on..
but i can’t say that i won’t enjoy this =P heh

h1

Test

August 10, 2011

Matrix[] transforms = new Matrix[myModel.Bones.Count];
myModel.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in myModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index];
effect.View = camera.View;
effect.Projection = camera.Projection;
}

mesh.Draw();
}