Search

Login



Privacy Policy

New user sign-up is disabled because of spam bots harassing this domain. Until I found a working solution, you can use the contact form and ask me for a new account. Sorry.
-Cygon

Advertising

Home Blog

Blog
Mocking the Input Print E-mail
Written by Markus Ewald   
Thursday, September 02 2010 09:40

I have updated my input library to a level where I think I can release it into the Nuclex Framework now. The design was tailored to make the input manager mockable (replaceable with a dummy object for unit testing), but the effort of mocking the entire input manager (versus just one input device) on an ad hoc basis was a bit too high (or too unreadable when using a dynamic mock object library).

So the final revision has mocked input devices and a matching input manager built in:

UML diagram showing the IInputService implemented by a real and a mock manager

 
New Component: Nuclex.Input Print E-mail
Written by Markus Ewald   
Monday, August 23 2010 15:12

The word 'Nuclex' in a stylish font framed by an elliptical ring with three dots

Developers following my twitter feed may already know that in the past few days, I've been working on a new component for the Nuclex Framework: Nuclex.Input. This component aims to solve all problems I ever had with input devices in XNA :)

It's a very simple library that provides input device classes similar to the ones in XNA (Keyboard, Mouse, GamePad), but instead of 4 game pads, there are 8 (with indexes 5-8 for DirectInput-based controllers). All input devices provide events (like KeyPressed and CharacterEntered on the keyboard or MouseWheelRotated on the mouse, for example). Here's a quick run down of the features:

  • Well-behaving keyboard text input

    • Honors keyboard layout and system locale
    • Supports XBox 360 chat pads
    • Very easy to use: just subscribe to an event
  • Support for standard PC game controllers

    • Works with any DirectInput-compatible controller
  • Mouse movement with sub-pixel accuracy (postponed)

  • Allows event-based input handling

    • Fully type-safe: events instead of message objects
    • Only compares states if events have subscribers
    • Mouse and keyboard don't have to compare states at all
  • Zero garbage: doesn't feed the garbage collector

Curious? Click on "Read More" to view some code samples!

This component will be in the next release of the Nuclex Framework!
If you want it now: Nightly builds, Source code (svn)

 
My Screen works Again :-) Print E-mail
Written by Markus Ewald   
Thursday, August 19 2010 11:45

Last Friday (and I only now notice it was Friday the 13th :D) my screen stopped working. I dismantled it and found some bad capacitors, then decided to do a small foto story showing my attempt to get it working again: My Screen went Dark :-(.

Today the electronics components I ordered arrived and I could finally replace those capacitors I found to be broken last time.

Picture of the top side of my 204B's power supply board with the new capacitors in place

Soldering in the new capacitors was surprisingly easy. I remember that when I did this in my childhood, I spread solder everywhere except where I wanted it to ;)

 
Quo Vadis, Input System? Print E-mail
Written by Markus Ewald   
Tuesday, August 17 2010 18:08

I've spent some time thinking about how input is handled by my GUI library. One issue I didn't cover in its initial design is that people might want to use the GUI library at the same time as their game is running (think of a command palette in a strategy game). I've already got some requests on the CodePlex forums (How to determine if a screen-position (i.e. mouseclick) is on any gui-control ? and Unfocusing from GUI) and it's about time I did something about this.

In the old design, an IInputReceiver was fed by one of two classes: one was the XnaInputCapturer which relied completely on XNA's input device classes (Keyboard, Mouse, GamePad) to track the status of any input devices, the other was the WindowInputCapturer which intercepted incoming window message for XNA's main window to obtain the status of input devices:

UML diagram showing the input system with two distinct classes for XBox and Windows input

This wasn't even nearly an ideal solution because now I would have to copy & paste the game pad polling code from the XnaInputCapturer to the WindowInputCapturer if I wanted game pad input on Windows. The new design should fix this, but still follow the concept of routing all input through a single interface (IInputReceiver) to allow users to easily attach the GUI to their own input handling code.

 
My Screen went Dark :-( Print E-mail
Written by Markus Ewald   
Friday, August 13 2010 21:17

Earlier this year, one of my monitors started behaving strangely each time it was turned on the first time for the day. The image would flicker on and off, first very slow, maybe twice a second, then faster and faster still until it displayed a permanent and stable image.

Over time, things got worse. First it would take just a few seconds, then two months later, the scree would stay black for minutes before the now familiar flickering started and the display settled. This morning, the display just remained black.

Picture of a Samsung SyncMaster 204B TFT LCD display

Some googling revealed the likely cause: bad capacitors. Between 1999 and 2007, many electronic parts were sold with bad capacitors because, at least that's a popular story, one Taiwanese company had obtained the knowledge to build electrolytic capacitors via espionage, but the informations were incomplete and the electrolyte was missing and certain agent that prevented the hydrogen from escaping.

Whatever the reason, my TFT's production date falls into the problematic range and symptoms are similar to things other people reported. So I went ahead and tried to take a look at the thing, documenting each step with my camera.

 
I see a Definitive Possibility... Print E-mail
Written by Markus Ewald   
Friday, August 13 2010 13:02

...that my artillery turret could have some issues with its scale!

Screenshot of an artillery turret that dwarfs the entire landscape

 
To GameComponent or not to GameComponent Print E-mail
Written by Markus Ewald   
Friday, August 13 2010 11:50

XNA provides a neat little system for you to organize your game's different parts in: GameComponents. You can use them to modularize your game's subsystems, eg. have a GuiComponent, PhysicsComponent, SceneGraphComponent etc. so you avoid having all that code in your Game class, or can use them for your actual game objects in smaller games.

However, the GameComponent and DrawableGameComponent classes provided by XNA force you to reference the Game class. This is unfortunate if you want to use those components in a WinForms-based XNA application and gets in the way when you try to write unit tests for your components because now you have to create a dummy Game instance as well (and better hope that component won't go shopping for references in the Game's Components and Services collections as well).

UML class diagram of the GameComponent and DrawableGameComponent classes

Luckily, the GameComponentCollection used by XNA to store your components manages IGameComponents and updating/drawing are based on the IUpdateable and IDrawable interfaces alone, so there's nothing preventing you from rolling your own components without referencing the Game class.

 
Using Ninject with SunBurn Print E-mail
Written by Markus Ewald   
Wednesday, August 11 2010 13:31

First, let me say sorry if I seemed to be absent for the past months. I was quite burned out and didn't want to do much with computers during that time :)

My "XNA Game Architecture" series was left hanging, and right when it got interesting, too. I'll try to find the time to continue where I left off. For now, here's a small appetizer:

The letter N constructed from overlapping blue wave functions

Some weeks ago, Synapse Gaming offered their SunBurn Lighting and Rendering Engine for half the price. This was to good an offer to pass and so I now find myself being able to do much better lighting effects than I had ever hoped to achieve in my game.

The first thing I did was, of course, to adapt SunBurn to Ninject, a very tidy dependency injector that works on the XBox 360 and even on Windows Phone 7, into the SunBurn example application. This article gives a short overview about the overall structure and provides you with an example application if you want to give Ninject a try yourself.

 
AeroCapture Print E-mail
Written by Markus Ewald   
Sunday, June 20 2010 14:30

Whenever I needed a screenshot of some application for this website, I used an image editor to cut out the window's drop shadow, generated an alpha channel from its luminance, added that as a layer behind the actual application window and saved the entire thing again.

Today I wrote a small utility to automate this process for me: AeroCapture. Pressing the "Print Screen" key will take a screenshot of the active window, and save it as a .png in the My Pictures directory, retaining the window's drop shadow in the image's alpha channel.

Screen capture of a small window showing a clip art of a digital camera

You can download it here: AeroCapture.7z (C# source code included)

This got me thinking. Somehow, whenever I have the choice between...

  • spending 2 minutes doing a repetitive task that I've done a few dozen times before already (like fixing up the screenshot for my website)
  • or spending 4 hours to automate the task

...I always choose the 2 minutes approach. I can continue working on what I was planning to do and I don't have as many utilities to maintain.

What do you do in this situation?

 
Visual Studio 2010 Print E-mail
Written by Markus Ewald   
Friday, April 30 2010 08:10

Two weeks ago, Microsoft released Visual Studio 2010 and with it, .NET 4.0.

I'm very excited about .NET 4.0 because this is the first standalone release of .NET since 2.0 came out, meaning that it doesn't bundle any of the older runtimes. As you may know, .NET 3.5 is actually just .NET 2.0 with some more assemblies - all the magic required for LINQ, extension methods and lambda expressions happens in the compiler.

The letter N constructed from overlapping blue wave functions

The new Visual Studio UI also looks very nice and the darker background puts the actual work (the code) into focus. But there have been some changes like the apparent removal of the Debug/Release combo in the toolbar and the ability to add your own External Tools to the Tools menu in the Express Editions (don't worry, both are still there, I explain how to enable them a bit down in this article).

So I decided to write a small heads-up on why I think Visual Studio 2010 and .NET 4.0 are cool and how to get back your favorite options if you're already used to the Visual Studio 2008 Express Editions.

 
<< Start < Prev 1 2 3 4 5 6 7 Next > End >>

JPAGE_CURRENT_OF_TOTAL


Joomla Template by Joomlashack