19 April 2007

I wanted to have my game panel run inside a splitter with a collapsible properties panel. This was quite easy to achieve, merely needing the changing of the handle that directX was pointing at. i.e. changing this:

d3dDevice = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this, flags, d3dpp);

to this:

d3dDevice = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this.panel1, flags, d3dpp);


But-it-broke-my-game.

How? The OnKeyDown event doesn't percolate to parents. That truly sucks. Oddly the only key that does percolate is ALT+key which windows needed to get menu key-presses (ALT-F,X) -- ain't that just too hacky. The mechanism is there, but disabled to frustrate us.

I didn't really want my players to have to play while holding ALT ;) so I went and figured out how to use DirectInput, with the aid of Riemer's tutorial. And it just works. Quickly.

I'm polling the input from my main loop now, and compared to the handling of the OnKeyDown event I'm getting squagillions more keypresses. Needless to say ints became floats (Vector3s actually) rather quickly to handle the smaller iterations.

Other changes include having to have to input de-bounce. I do this by copying the previous state's keys and passing them into the next input parse.

private List Input(List laststate)
{
List seen = new List();
Vector3 rotationInput = new Vector3(0, 0, 0);
KeyboardState keys = keyb.GetCurrentKeyboardState();
if (keys[Key.Escape]) this.Dispose();
if (keys[Key.W]) rotationInput.Y++;
...
if (keys[Key.P] && !laststate.Contains(Key.P))
{
PropertyGridVisible = !PropertyGridVisible;
splitContainer1.Panel2Collapsed = !PropertyGridVisible;
OnResetDevice(d3dDevice, null);
}

...
return seen;
}

And in the main loop:

static void Main()
{ ...
using (Game grav = new Game())
{ ...
List laststate = new List();
while (grav.Created) { ...
laststate = grav.Input(laststate);
... }}}

The debouncer was necessary to do 'edge detection' on the squagillion keypresses that I was getting, e.g. to toggle the property pane once only. The extra call to OnResetDevice is to handle the change in FoV which is done based on the current size of the panel.



End of dev iteration.

Posted on Thursday, April 19, 2007 by Unknown

No comments

17 April 2007

Update: I'm using MDX, Rein's using XNA and Colin has joined us using GL.

My first deliverable was to have an object in a scene with tilt-to-steer and gravity.

This is done.



yay!

The object


The object is a triangle list primitive with a single triangle in it. Each vertex is differently coloured to help with orientation. It whizzes around quite satisfactorily with a simple spring function restoring it to zero-tilt, resulting in a max thrust of about 70deg.

Gravity


Gravity... sucks. Really.

Inverse r-squared explodes quite quickly near to the centre, I had great fun experimenting with my singularity-like point-source gravity and watching things magically teleport off into the far reaches of game-space, never to be seen again. Okay, maybe frustration as well as fun ;) .

Other things



  • I'm thinking of a few weapon types: a shotgun of low-damage point-bullets, thrust based rockets (possibly steerable).
  • Planets should bubble into their positioins from the deep below the playing surface, with a bouyant-spring effect upon arriving. The gravity field vis should ripple away from them as they arrive.
  • Thinking of indicating a planet's power charge by encasing the planet in a platonic solid, increasing/decreasing count to indicate power. Maybe CTF-style planet capturing? Perhaps charged planets repel craft.
  • Sitting in a gravity field charges the batteries in proportion to the strength of the field. See, in the future they've figured out how to generate power from gravity: It's a cunning arrangement of pulleys, levers, cats and buttered toast.

Posted on Tuesday, April 17, 2007 by Unknown

No comments