Dream, Build, Play looks live!!!!
Month: January 2007
Multithreading for the Xbox 360
When multithreading on the Xbox 360, here are a few things to keep in mind.
Affinity
In multithreaded programming, programmers often lack the ability to specify the Processor Affinity of a thread. Even when API calls are available to specify a processor, it is usually ignored. The reason for this is that modern operating systems have many processes running, each with many threads. The operating system zealously manages processor affinity in order to maximum some metric.
Halo 3 Beta
I have been chosen for the Halo 3 beta… this is awesome!
I received the email yesterday, but it went to my hotmail account (which I rarely check). This is perhaps the best email I have ever received.
I think they have just given me a reason to check my hotmail account more often:
"Keep an eye on your inbox, we will be sending more information about this opportunity soon."
The Game Of Life
I had been thinking about creating a version of Conway’s Game Of Life for XNA, but it would appear that I was beat. I just found this one, which is far nicer looking than anything I could have thrown together.
Throwing More Than Just Exceptions
It is a little known fact (and probably for the best) that the CLR can throw and catch more than just System.Exception and its children. In fact, the CLR can use any type as if it was an Exception.
.assembly ExceptionTestAssembly {}
.class public ExceptionTest { //custom class
//note that ExceptionTest does NOT extend System.Exception
.method public void .ctor(){
.maxstack 1
ret
}
.method static void main() il managed{
.entrypoint //program entry point...
.try {
newobj instance void ExceptionTest::.ctor()
throw //throw a random object
} catch ExceptionTest { //catch the random object
pop
ldstr "Random object caught"
call void [mscorlib]System.Console::WriteLine(string)
leave.s OUT
}
OUT: ret
}
}
Embedding Assets Into Your XNA Game
Currently I am a working on a small XNA project whose solution is composed of 4 projects, a DLL, a Windows Game, a Xbox 360 game, and a level editor. Each projects needs access to my assets (currently just 2d sprites), and has raised the interesting question of how to easily share them between each project.
What I had been doing was adding the assets to the Windows game as pipeline content. After compiling it I would then copy the compiled assets from the bin directory, to the bin directories of the level editor and the Xbox 360 game. While this worked, it was error prone and time consuming.
Instead I found that I can add my assets to the DLL as embedded content, and then load them at runtime. Normally you would have probably loaded content by calling the "Load" method of "ContentManager", like:
_content.Load<Texture2D>("mySprite");
As stated above, the problem with this solution is that "mySprite" would have had to been compiled into the content pipeline. When your assets are added as embedded content, the above method does not work. Instead, you can load your content like this:
Assembly asm = Assembly.GetExecutingAssembly();
Texture2D.FromFile(_graphicsDevice, asm.GetManifestResourceStream("SampleProject.Textures.mySprite.png"));
Xbox 360 Button Icons
I guess its true that old news is new news if you’ve never heard it before. In case anyway else missed this, back in September Sinnx at 360P posted Xbox 360 Button Graphics.
Lisp interpreter for XNA
I just found a Lisp interpreter for use with XNA. It was created by Jon Watte in C#, and is compatible with both Windows and the Xbox 360.
For those who are unfamiliar with Lisp, it is a high-level functional language created by John McCarthy in 1958. Lisp is commonly used by artificial intelligence researchers, and could come in handy for adding in-game AI to your next XNA project.
Cookie Renaming in ASP.NET
In ASP.NET you can seamlessly rename cookies on the fly with the help the PreSendRequestHeaders and BeginRequest events of the HttpApplication class.
Both events call EventArgs delegates, with the sender object as a HttpApplication instance.
///