DavidSB

Hey

I'm fairly new to programming and have created a basic 2D vertical shooter for a university project. Now the code is very dirty and needs alot of optimizing but I am new to all this so not entirely sure how to do it properely. As it stands everything is done in the game1.cs code file. I know this is not how its suppose to be done.

The problem is its slow and jerky on my 360 and not on my pc. Just wondered if there was a quick way to speed up to code, or as the way I've writte the code its just going to be slow on the 360.

If I post my source up somewhere, could some of you guys take alook at it and give me some advice Whats the best place to host a file

Regards

David


Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

easlern

Yeah, I'm sure people would be happy to offer suggestions. You can post the code here, unless there's an academic policy that would prevent it of course.



Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

Joel Martinez

Your problem is more than likely related to the Garbage Collector. Or more specifically, not structuring things in such a way as to play nicely with the GC on the 360. Read the following article and the articles it links to for more info :-)
http://blogs.msdn.com/netcfteam/archive/2006/12/22/managed-code-performance-on-xbox-360-for-the-xna-framework-1-0.aspx





Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

DavidSB

Hey Joel

Thanks for the links will give them a read.

I've uploaded just my game1.cs at

http://www.threesixbox.com/project id=c11a64b63e

If some people could take a look I'm sure theres obvious things that need cleaning up, but as I said I not really sure how to go about doing it.

Thanks for any help or directions people can point me in.

regards

David




Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

Brandon Bloom

You should load all of your textures during the call to in the LoadContent(true) and then store those in a lookup table rather than your jumble of if statements. Your code will be much shorter, will likely run faster, and will be much easier to scour for the real problem :-)



Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

DavidSB

Thanks Brandon, I understand what you are saying, but not to sure how to implement this, an example would great. Thanks very much.

Regards

David




Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

Ely

Hey David,

I agree with Brandon that the slowdown is probably caused from all the texture loads you are doing. It seems every time a game state changes you are loading a texture, and when that happens the game has to hit the disk, read the file, and put it into memory. Then you have to wait for the garbage collector the get rid of the old texture. You should read all your textures in the LoadGraphicsContent method. To deal with the change in states, you could load all your textures at once, and then just draw the appropriate one (for instance, different textures for ship, shipDown, shipRight, etc..), or you could combine all your textures into one file (called a tileset), and only draw a certain section of the tileset based on your state. http://www.xnaresources.com has a good tileset tutorial that does this.






Re: XNA Game Studio Express 2D Code slow on 360 but fine on Pc

Brandon Bloom

I threw "C# arrays" into Google, this will likely help you:

http://www.c-sharpcorner.com/Code/2002/July/WorkingWithArrays.asp