Archive for April, 2011

Game Concept: Fading Opportunities

Friday, April 29th, 2011

The following is the first in a series of game concepts that I thought would be good to get written down for future use or inspiration, either for myself or for anyone else who wants to take the idea further. Be sure to let me know if you make use of it – I’d love to see it fleshed out into a playable game.


Fading-oportuinties

A simple character that presents an element of reality: no matter how hard we try, the results usually only last a short time before fading away.

This main character has the ability to create opportunities. Initially, I imagined these opportunities to be represented as stairways that could lead to new areas in the environment. But like our efforts in the real world, these stairways eventually fade away sometime after their creation – or in this world, very shortly after their creation.

As a game where the character uses his or her powers to explore the environment, similar to the Paper Mario series, it’s natural to expand the player’s abilities and powers for more gameplay options. Instead of only being able to only create stairs, maybe he can also create doorways into new areas. Barriers could be created to prevent enemies from attacking you, etc. This kind of gameplay would lead naturally into a reusable world/environment or sandbox.

All of this could be intertwined with a story explaining the struggles of the character and the limitations of his power. Through many trials and growth, the character will overcome obstacles and achieve new heights previously unimagined.

IGDA Ottawa: Indies in the Classroom Talk

Friday, April 22nd, 2011

At a recent Independent Game Developers Association meeting I was asked to talk about my experiences taking Hideout!, a project originally developed as schoolwork, to the Xbox 360 for public sale. The slides and a video of the presentation are below. As always, please pass on any feedback; it’s always much appreciated!

The presentation began with a brief introduction of myself and Hideout! including Hideout’s promotional video.

This meetup was focused on students going above and beyond class requirements and taking their games to the next level. The audience was comprised mainly of students in game development programs or recent graduates. The topics covered include the following:

  • Porting from Windows to Xbox 360 with XNA
  • Xbox Live “Indie Games”
  • Other general game design topics for Hideout!

Download Slides (PPTX)

Changing the Windows Mouse Cursor in XNA

Monday, April 4th, 2011

aero_arrow

Background

For anyone who is looking to develop a mouse-based game for Windows using the XNA framework, it’s pretty critical to be able to change your mouse cursor in game. The first method is to hide the mouse cursor and draw a custom texture in place of it – but anyone who is developing a game that might not be running at a full 60 frames/sec will know that this is does not work well, as it results in a very slow and unresponsive mouse movement.

The Windows operating system is designed to give extremely responsive mouse movement no matter how slow your applications are running, so we’d like to harness this power in XNA while also giving us the power to change our cursors.

Overview

The following will allow you to change the windows cursor in XNA to any .cur or .ani file (full colour, animated, just like through the Windows Control Panel). This is done by changing the cursor of the windows forms handle for the XNA window. To load full colour and animated cursors, we will use the IntPtr LoadCursorFromFile(string) method from user32.dll, as suggested by Hans Passant.

Step 1: Add References

  • Add the “System.Windows.Forms” reference to your game project. Do this by right clicking on the References folder in the Solution Explorer for your project and select “Add Reference…”. It can be found under the “.Net” tab.
  • You will need to include the following namespaces:
using System.Windows.Forms;
// For the NativeMethods helper class:
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Reflection;

Step 2: Add your Custom Cursor

  • Add cursor to your project (let’s say it’s called “cursor.ani” and you put it in the “Content\Cursors” directory).
  • Go to the Properties of this cursor in your Solution Explorer and set the “Build Action” to “None” and “Copy to Output Directory” to “Copy if newer”.

Step 3: Loading The Cursor

You will need something like the following helper method to load your full colour animated cursor into a handle that Windows Forms can use:

// Thanks Hans Passant!
// http://stackoverflow.com/questions/4305800/using-custom-colored-cursors-in-a-c-windows-application
static class NativeMethods
{
    public static Cursor LoadCustomCursor(string path)
    {
        IntPtr hCurs = LoadCursorFromFile(path);
        if (hCurs == IntPtr.Zero) throw new Win32Exception();
        var curs = new Cursor(hCurs);
        // Note: force the cursor to own the handle so it gets released properly
        var fi = typeof(Cursor).GetField("ownHandle", BindingFlags.NonPublic | BindingFlags.Instance);
        fi.SetValue(curs, true);
        return curs;
    }
    [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    private static extern IntPtr LoadCursorFromFile(string path);
}

Step 4: Changing the Cursor

First, set the mouse to visible:

this.IsMouseVisible = true; // in your Game class

Next, load your cursor using the above static helper method:

Cursor myCursor = NativeMethods.LoadCustomCursor(@"Content\Cursors\cursor.ani");

Now load up the window handle that will let you change the window’s cursor:

Form winForm = (Form)Form.FromHandle(this.Window.Handle);

Simply do the following to change the cursor:

winForm.Cursor = myCursor;

That’s it! Happy game dev-ing!