Tampilkan postingan dengan label xna. Tampilkan semua postingan
Tampilkan postingan dengan label xna. Tampilkan semua postingan

Xna Feature Request

Diposting oleh good reading on Selasa, 29 Mei 2007

Kris is soliciting votes for an xna feature -- GameServiceContainer.GetService<T>
(i.e. Make GetService support Generics!)

Follow the link and click "vote now".

Use your MSDN/Live credentials to log in.

If you get a page not found error, you need to complete registration for Microsoft Connect -- go to the "My Participation" link in the left menu.
More aboutXna Feature Request

XNA Content Builder

Diposting oleh good reading on Rabu, 21 Februari 2007

Let's you build xna content w/o Game Studio Express!!
You can get it here

Thank you!! And thanks Kris for sending me this link :)
More aboutXNA Content Builder

Xna, graphics and team edition, oh my

Diposting oleh good reading on Sabtu, 17 Februari 2007

The next step in my quest to only code my xna games in team edition was working with graphics. This proved to be a little more difficult because graphics need to be built inside Xna projects.

So, I needed to break my rules a little...
New rule:
Graphics can live in an Xna library, that is neither living in the main game solution or the GameShell exe assembly.

In Xna, graphics are just content loaded from disk built as "xnb" files, so they only need to be in the TitleLocation of the StorageContainer when your game is running (this is where the ContentManager Loads). If you look at a project containing pipeline content, you'll see an ItemGroup node:

<ItemGroup>
<Content Include="Image.jpg">
<XNAUseContentPipeline>true</XNAUseContentPipeline>
<Importer>TextureImporter</Importer>
<Processor>SpriteTextureProcessor</Processor>
<Name>spriteImage</Name>
</Content>
</ItemGroup>

So, if you wanted to, you could create an Xna library project and then just add content to it manually by copying images into a child directory and adding xml to the project file. Or, you can keep Express edition open for your graphics and build them as you need them.

So, now I have a graphics library with all my assets. Once it builds, I need to put these files in my debug directory if I want to use them, but as one of my stipulations, I didn't want to have any post build steps, so I made the following modifications to my Program.cs class in GameShell:


for (int i = argIndex; i < args.Length; i++)
{
string graphicsPath =
Path.Combine(args[i], @"bin\x86\Debug");
if (Path.IsPathRooted(graphicsPath) == false)
{
graphicsPath = Path.Combine(projectPath, graphicsPath);
}
foreach (string file in Directory.GetFiles(graphicsPath))
{
File.Copy(file, Path.Combine(debugDirectory,
Path.GetFileName(file)),
true);
}
}

Basically, I added the logic to the GameShell that any additional parameters to the application are graphic resources. If the resources aren't rooted, there are libraries inside the main project directory. So, this just goes through all those folders and copies all the files -- simple.

Still with me? This is a long one... BTW -- I have never even tried to run this on my xbox, I do all my coding on my laptop on my long ass ride home on the train so I take no responsibility for your boxes :P Also, if someone came up with a better solution, please tell me cause I'm without internet on this long ass train ride!

Yay, so now I have all the assets I need :)

Or so I thought...

I couldn't load any of these xnb resources. The content.Load was only working with resources in the bin directory GameShell :(

Reflector to the rescue...

I found this bit of code, used to determine where to find graphics:

public static string TitleLocation
{
get
{
string text1 = string.Empty;
Assembly assembly1 = Assembly.GetEntryAssembly();
if (assembly1 == null)
{
assembly1 = Assembly.GetCallingAssembly();
}
if (assembly1 != null)
{
text1 = Path.GetDirectoryName(
new
Uri(assembly1.EscapedCodeBase).LocalPath);
}
return text1;
}
}

As you can see, its using the entry assembly (or calling assembly) to determine the location of content...

So, back to my original solution with the app domains... oooo I was being clever :P

A few minutes of hacking in some appdomain code and voila, the game will only execute in the main appdomain... d'oh -- wasn't being clever after all, but I think I got that out of my system.

Returning back to my graphics copying code, I decided the simplest approach is copying the assets into the TitleLocation in Program.cs. A slight modification to the file and finally, I'm debugging my Game in Team Edition with Graphics!!!

And there was much rejoicing... yay.

I think I've put off writing some games long enough :P
More aboutXna, graphics and team edition, oh my

i just can't do it...

Diposting oleh good reading on Senin, 12 Februari 2007

Code without resharper and visual assist that is...

After 10 minutes of my first Xna tutorial, I decided my first task would be to do all my developing in team edition.

Being my own customer, I made up the following criteria:
1. I can create a new c# library in vs team edition that contains a Game class which can be debugged/run from vs team edition
2. No post build copying of project output
3. No need for maintaining 2 separate solutions for each game
4. No dependencies between my game projects

In order to fulfill these, I created a new Xna solution called GameShell. I deleted the Game class, leaving Program.cs which I filled in with this code:
static void Main(string[] args)
{
string assemblyFilename = args[0];
string path = args[1];

Environment.CurrentDirectory = path;
Assembly assembly = Assembly.LoadFile(Path.Combine(path, assemblyFilename));
string typeName = args[2];
Game game = (Game)assembly.CreateInstance(typeName);
game.Run();
}

I used Assembly.LoadFile, because using Type.GetType(gameTypeName) was returning null... I don't think anything was spelled wrong, but I was feeling lazy, so I used the code above...

Its sad to admit, but before I thought to set Environment.CurrentDirectory, I had created a new appdomain that was rooted in the other directory and had a lovely class, GameStarter : MarshalByRef, that created and ran the game, which I thought was very clever, but completely unnecessary)


Now that I had GameShell to execute my game, I needed a game to run. I created a c# library in Team Edition, added references to Microsoft.Xna.Framework and Microsoft.Xna.Game and then added a game class to the project. Actually its Game1 from the first tutorial from the documentation (very exciting). Now that the project was ready to debug/run, I went into the project properties and changed the Debug settings so that it ran GameShell.exe with the proper command line arguments (AgileSolutions.GameLib.dll, FullPathToDebugDirectory, AgileSolutions.GameLib.Game1)

Viola! The game ran and I can now write any game library with my favorite tools and run it without any headaches... one minor issue though, graphics... you know, not the most important part of the video game, right?

For this first project, I cheated and put my graphics in the GameShell assembly, a big no no, but I'm gonna do some reading and learn more about content pipeline assets and we'll see what happens. Any ideas?
More abouti just can't do it...

XNA

Diposting oleh good reading on Rabu, 07 Februari 2007

In addition to this very exciting blog, another goal for the year is to experiment with a new technology. Originally I was going to play around with Ruby, but I've decided to try out XNA instead. I was all psyched and ready to embark on the journey to creating my first xbox game when I discovered the following:

1. XNA development is only supported in VS Express addition!!! This is most upsetting because I cannot work without resharper and visual assist. Really, I can't. I keep doing things like ctrl-b, ctrl-alt-F7, ctrl-alt-v, shift F6, the list goes on... And intellisense without the ability to misspell just does not work well for me... I need colored listboxes!!!

2. No xbox live support :( this wasn't as much of a downer as #1, but I was looking forward to making up some clever achievements

3. How am I to test drive without add-ins? This really goes with #1, but this isn't about making development easier, this is about how I develop.

Despite the above, I'm still excited about my game idea and I hope its fun!

Wish me luck
More aboutXNA