Archive for September, 2008

Scurvy.Media Question

I received a question about the Scurvy.Media library, and I figured I’d share my response in case it’s useful to anyone else :-)

Hi Joel,

We are currently doing a project in XNA and are trying to inventory the abilities to play video in game. We found the scurvy media project to be the one that is the most advanced. Only on your codeplex site it is not really clear what the requirements are of the movie to be played. so far i’ve gathered
- it should not be compressed video (xvid / divx)
- framerate game = framerate video

could you please respond to tell me if the information i’ve gathered is correct?

That’s partially correct :-)  

  • Theoretically, as far as compression goes, you can use whatever codec you want … as long as the developer’s machine has the same codec.  I’ve heard some reports of certain videos not working for certain people, but I’ve no way to determine whether they have the correct codec installed :-P   Beneath the scenes, the content pipeline portion uses this library to decode the AVI video.  So as long as that library can read it (and it just uses your machine’s codecs), then scurvy.media should be able to translate it to the runtime format.
  • As far as the framerate goes … as long as your game’s framerate does not drop below the framerate of the video, the video will play at the correct framerate.  It takes the video’s length and frame length into account … it’s just that if the game delays an update call to the video, there is no built in recovery mechanism for it to catch up.

A few more things to note … the pipeline is unfortunately sensitive to video size.  Because of the way that it decodes the video into essentially a sequence of textures, the size can tend to be a little large.  This would be fine if it was able to get on disk, because of the way that the video is streamed from the file system.  But unfortunately, the content pipeline buffers the entire contents of one .xnb file in memory first before writing to disk … so if this hits some limit, it will throw an out of memory exception.  I usually just suggest that users break down the video into multiple ones and play them sequentially if it’s too long.  I know it’s less than ideal, but it’s the workaround for the moment.

I wish your project the best of luck … please keep me informed of your progress using the library if you end up using it as I’m always looking for ways to improve it and user’s feedback is always instrumental in this.

Comments (4)

Self-Improvement Through Creation

If you happened to catch the presentation I gave at ONETUG last month, you’d know that one of the main points of that presentation was constantly learning and developing your own skills by doing personal projects on the side using XNA.  I was pleasantly surprised when I opened up the latest GameDeveloper magazine and found an article by Masaya Mastuura, the mind behind Parappa the Rapper, called A Sense of Fun.

I’ve excerpted a section below and added some emphasis on a few of the sentences:

Most musicians create music in their own style, even when they have been asked to make something specific.  Many incapable music directors do not even think of starting musical production until after the taste of the game has been decided by the planning, design, and graphics teams. For me, someone who is engaged in this kind of occupation cannot be called a musician.

This applies for more than just music. If you want to create something of value, then you must continue to create for yourself as well. It’s the same for designing games. If an artist only works on things that come to him through work, then all he is doing is production. Development is not coming from within. The scale and scope of the production, as well as the number of people working on the project should not put a damper on his creativity.

Lately, a lot of developers I know — especially programmers — have told me that they are making small scale games by themselves, independently. To develop something solely from one’s own potential is, I believe, a thing of importance. The contents of a game are a combination of passion and energy. If these are becoming sub-ordinate to other factors, then it is game over.

I hope if anyone took anything away from that presentation, that it was this.  Even though in retrospect it may seem that I was just lucky and jumped on the right bandwagon, one of the things that I had always wanted with respect to ONETUG was expand the local developer community to the point where central florida is a well respected center of excellence.  I feel that the local community has indeed expanded greatly since those early days.

The more that people work on expanding their own skill set, as opposed to only working on things that come to them from work — I believe is the more that the local community will expand and improve :-)

Comments (1)

May Their Stack Overfloweth

Just to give them some googlejuice, I wanted to link to the new programming community site StackOverflow.com. From their vision statement:

Stackoverflow is sort of like the anti-experts-exchange (minus the nausea-inducing sleaze and quasi-legal search engine gaming) meets wikipedia meets programming reddit. It is by programmers, for programmers, with the ultimate intent of collectively increasing the sum total of good programming knowledge in the world. No matter what programming language you use, or what operating system you call home. Better programming is our goal.

I have to say that I love the idea of someone unseating experts-exchange.  I’ve always hated the fact that these answers show up on google, and they try to trick you into signing up just to see the answer. 

And I also really like the way that they are changing the way that a community site is structured.  I’ve been a member of many many many an online forum, and I have to say that I’m tired of the same ol’ paradigm of the forum.  And they also use OpenID! :-P

So to them I say, Best of Luck!

Comments

Rethrowing Exceptions in .NET

Wow, I finally came across a good reason to rethrow exceptions using the “throw ex” syntax instead of just “throw”.  For those of you who don’t know, when you have a try/catch block, you have the option of rethrowing the exception so that it may be handled further up the call stack.  The most common reason you might want to do this is for error logging … so you can log the error, and then let someone else worry about the exception.

try
{
    // some exception to happen here
}
catch(Exception ex)
{
    throw;
}

The slight nuance that many people may not know is that if you just use “throw”, the exception’s stack trace is maintained.  But if you use “throw ex”, the stack trace will start from that method where you threw the exception.  Most people that don’t really know this end up using “throw ex”, and I’ve always advocated the use of “throw”.

Enter SqlExceptions.  When you log a SqlException, you will see at a minimum the following stack trace:

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader()

When trying to look at logs to investigate a crash, this is a lot of text for your eyes to parse through.  In this case, I find it better to catch the SqlException and rethrow it using this syntax:

try
{
    command.ExecuteNonQuery();
}
catch(SqlException ex)
{
    throw ex;
}

That way, you don’t get the ridiculously long stack trace from within the sql command that you don’t care about :-)

Comments (1)

Installing XNA 3.0 from Scratch

It’s by no means rocket surgery, but I recently cleared out an older laptop so that I can do all my XNA development there instead of taking up my other computer’s hard-drive.  So I figured I’d post the all of the apps that I installed and the install order in case it was useful to anyone else :-)

  1. Microsoft .NET Framework 2.0
  2. Visual Studio 2008 C# Express
  3. XNA Game Studio 3.0 CTP
  4. Paint.NET
  5. XSI Mod Tool

Feels good to “Start over” as it were, without having to have four different versions of visual studio (2k5, 2k5 express, 2k8, 2k8 express) and all the other development crud that goes into “the day job”

Comments

XNA Presentation Source

Apologies for the delay, but I finally got around to packaging up the presentation that I did in my ONETUG presentation in august.  For those who were not in attendance, the entire presentation was written in XNA.  I also ended up using the FlatRedBall engine to handle a lot of the rendering and collision.

I originally didn’t want to make a huge deal about the fact that I was using a third party engine because I wanted the focus of the presentation to be on techniques that you could use with or without an engine instead of specific APIs of that engine.  However, the meeting attendees seemed very receptive and interested in the engine anyways … which is great because FlatRedBall is a really great engine.  I wholeheartedly suggest checking it out because it makes a great many things so much easier.

Another surprise to me was that there was a lot of interest in the code that ran the actual presentation.  After an impromptu run-through of the code at the end of the presentation, I decided to put a few details for those who were interested (along with the download link below).

I had a great time doing the presentation and I wanted to thank all the good comments that came my way from it.  I would definitely be interested in doing another one that dives into some more detail, particularly 3D concepts which seemed to be a recurring request.

DOWNLOAD

http://codecube.net/bloguploads/AugustONETUGXNA.rar

  • Presentation class, handles the main presentation navigation.  Gamepad 1’s left and right bumper provided the "forward" and "backwards" navigation.
  • PresentationScreen class, handles secondary navigation between same-screen indexes.  Also handles the updating of all "IndexActions".  Gamepad 1’s A and B buttons provided the forward/backwards index navigation
  • IndexAction class, provides a simple mechanism to add custom functionality when a screen index is entered or exited.
  • *.scnx files, created using FRB’s SpriteEditor, each main presentation screen has one .scnx file, which itself defines multiple indexes using a naming convention.

Comments (1)