Archive for January, 2010

Chasing Dots – Our contribution to Global Game Jam 2010

Sunday, January 31st, 2010


This is the game we created at the Nordic Game Jam 2010.
Finally ... after liters of chocolate milk, coffee and chocolate.
After playtesting, debugging, playtesting, debugging.... etc for 48 hours - we finally have a playable version out.
The theme for this years Game Jam was "Deception" and there was a constraint saying that you had to have a DonKEY, a MonKEY or a KEY in your game.

We chose to make a little player-vs-player maze game. The hunter (black) is faster than the hunted (white) but the hunted can spawn clones of himself.
The KEY is used to unlock the teleports (red squares).

We are considering selling the game on Xbox Live Marketplace, but let's see :)

Here's a demo of the game - have fun and let me know what you think.
You will probably need to install the XNA 3.1 framework redistributable first, if you don't already develop XNA games.
Credits:

Project Manager/Music
Lars Nysom

Audio/Concept/Leveldesign
Rasmus Lønne

Code
Malte Baden Hansen
Jesper Eiby
Jakob Lund Krarup

Fanpic with Peter Molyneux :)

Saturday, January 30th, 2010

The Legendary Games Creator and a great fan!

I am attending the Nordic Game Jam chapter of the Global Game Jam that is going on this weekend in all timezones.
The keynote speaker is Peter Molyneux - and since I got the chance to meet a legend I just HAD to brag.

To all the Teenage-Game-Tycoons out there :)

Thursday, January 28th, 2010

Someone posted on the XNA Forums about how all of his projects gradually slowed down and finally ground to a halt far from being finished and far from being anything like what he was striving for.

The original post was deleted while I was responding - but since I know there are many TGT's out there I thought I'd post it here.
If you're a TGT - this one's for you!

"Well if you want to hear my solution:

Do a little and do it well
Start out simple - but finish it!
If you have to create XNA-tic-tac-toe or XNA-Pong for you to finish a complete game including titlescreen, options and help, then by all means DO THAT :)
Better to have a fully finished game to show off, expand and learn from than 20 barely-begun projects laying around.

Be proud of what you do - because YOU did it!
This has worked for me in many endeavors.
Continually praise yourself saying "well done - you finished another sprite/method/class/level" and remind yourself of how far you've gotten on this project.
It is really a benefit to have high thoughts about what YOU produce - even despite what others may think or compare your games to. :)

Join hands - it just makes for better results :)
Only start something by yourself if you are content with failure or another "draft-gone-prealpha-gone-stale" :)
Find someone on the forums to make your first little game with. All gameprogrammers started small, but very few got to where they are today without the moraleboost of being in a group.

Go get'em tiger!

Kind regards - Jakob "xnaFan" Krarup"

Nordic Game Jam this weekend – yay! :)

Wednesday, January 27th, 2010

This weekend a buddy of mine and I are driving to Copenhagen to participate in Nordic Game Jam.
The sign-up closed at 260 participants, that will be my biggest jam yet :).
For those of you who haven't participated in a Game Jam yet - DO IT!
Here's a short excerpt from the NGJ webpage about why you should try it. It sums it up pretty well:

But why participate in a game jam? And why go through 48 hours of: very little sleep, hard work, great ideas, crunching, problem solving & technical issues? Because a game jam encourages innovation and experimentation. It is one of the vehicles behind the new generation of game developers that can experiment with platforms and game ideas in an intense and yet still informal atmosphere. This is the space where the new generation of talents can be found.

If you urge to create a game, collaborate and meet other game developers - then Nordic Game Jam is the perfect place for you. As a participant at the Nordic Game Jam you will be part of a global event of creativity and fun.

The Nordic Game Jam 2010 will follow the same format like previous years, as an event where students, hobbyists and professional game developers, meet up for a weekend to develop and experiment with new and innovative game ideas.

My version of the 10 second pitch sounds like this:
"It's an excellent chance to pick up new skills and friends while doing what you like best - code XNA ;-)."

Nordic Game Jam will be opened by Carina Christensen, Danish Minister of Culture - which I think is a proper recognition for the role games play in the development of a common culture.
But more importantly: Peter Molyneux, yes THE Peter "Populous-DungeonKeeper-Black and White" Molyneux will be doing the Keynote speech.
To me Peter is synonymous with Artificial Intelligence. Like no other he made me believe that the characters you saw on the screen had a life of their own, even after turning off the PC :)

Can hardly wait!

XNA extension methods page

Sunday, January 24th, 2010

Just a short note to let you know that I will gather my extensionmethods on a separate page with sample usage for handy reference.

XNA Pixel Robots library

Wednesday, January 20th, 2010

A while ago I came across Dave Bollinger's PixelRobots and PixelSpaceships:

Unfortunately his website is gone now :-(, but his work has not been in vain, as this C# version lives on :).

His website is still available on the WayBackMachine, so you can go look at the algorithm for pixel robots and pixel spaceships. In case they ever disappear, here's a zipped PDF print.

Dave, if you're out there, I hope you don't object to me storing your lost treasure for the rest of the world to enjoy your creation :)

He has invented a way of generating simple, random robot-like or spaceship-like sprites. His code will generate many different versions of the millions and millions of possible variations of robots and spaceships. I really liked the idea, and thought that it would be very nice to have an XNA implementation for anyone who needed generic spaceships or robots in a game. So I created an XNA version from his description.

You don't have to understand the internals of neither Dave's code or my API to use this code, as everything is wrapped up in simple methods. But all the helpermethods and variables are available for use if you want to create something more advanced.

It can be as simple as this:

//create two bitmaps scaled by 5 with different colors
Bitmap spaceship = PixelMaskGenerator.GetCompletedRandomSpaceshipImage(5, Color.CornflowerBlue);
Bitmap robot = PixelMaskGenerator.GetCompletedRandomRobotImage(5, Color.LightGreen);

The above code would generate the following two images:

If you'd rather generate SpriteSheets and then use them as Content files instead of creating the spaceships runtime there's also support for that. The spritesheet below was created with the following code:

//create spritesheet
//scaled 3 times, 10 rows and 10 columns
//using spaceships in CornFlowerBlue
Bitmap spritesheet =
PixelMaskGenerator.GenerateRandomSample(3, 10, PixelMaskType.SpaceShip, Color.CornFlowerBlue);
spritesheet.Save(@"C:\spritesheet.png");
spritesheet.Dispose();

Samples spaceships

And then if you need to convert the Bitmaps to Texture2D runtime, it can be done in XNA 4.0 with Florian Block's code:

//Converts a Bitmap to a Texture2D
//Code found here:
//<a href="http://florianblock.blogspot.com/2008/06/copying-dynamically-created-bitmap-to.html):">http://florianblock.blogspot.com/2008/06/copying-dynamically-created-bitmap-to.html):</a>

private Texture2D BitmapToTexture2D(GraphicsDevice dev, System.Drawing.Bitmap bmp)
{
    Texture2D customTexture = new Texture2D(this.GraphicsDevice, bmp.Width, bmp.Height);
    BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);

    // calculate the byte size: for PixelFormat.Format32bppArgb (standard for GDI bitmaps) it's the hight * stride
    int bufferSize = data.Height * data.Stride; // stride already incorporates 4 bytes per pixel

    // create buffer
    byte[] bytes = new byte[bufferSize];

    // copy bitmap data into buffer
    Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);

    // copy our buffer to the texture
    customTexture.SetData(bytes);

    // unlock the bitmap data
    bmp.UnlockBits(data);

    return customTexture;
}

Code
The Download code is available here.
The solution includes three projects:

  • PixelRobots is the main project is the project which contains all the code needed to generate SpaceShips, Robots and SpinedRobots (robots that are ensured a cohesive spine) for your game.
  • ConsoleTester is a consoleproject which goes through step-by-step what is done behind the curtains. It saves the generated images to disk and displays them in an HTML page.
  • TestingPixelRobotsInXNA is a little XNA demo which lets you generate spaceships with the left mousebutton and robots with the right mousebutton.

TestingPixelRobotsInXNA

I made a short video presenting the API in use in TestingPixelRobotsInXNA:

Hope it is of use to somebody - it was fun making :)
If you use it for something I'd love to see for what.

More links
Want your own PixelRobot Tee?
Want the code in PHP for your website?
Want to see the PixelRobot idea used in a windowsgame? (non-XNA)

MouseState ExtensionMethod

Wednesday, January 20th, 2010

Just a little helpermethod to get the mouse's position as a Vector2.

For those of you who still haven't gotten started with extension methods here's a quick writeup'n'sample

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace XNAFAN
{
public static class MouseStateExtensionMethods
{

///

/// Returns the mouseposition as a Vector2
///

/// The current MouseState /// The mouseposition as a Vector2
public static Vector2 GetPosition(this MouseState mouse)
{
return new Vector2(mouse.X, mouse.Y);
}
}
}

This way you don't have to convert x and y every time along the lines of
MouseState mouseState = Mouse.GetState();
Vector2 position = new Vector2(mouseState.X, mouseState.Y);

Instead you just add a reference to the code with the extensionmethod and this enables you to write:

Vector2 position = mouseState.GetPosition();

Nifty - eh...? :-)