Tuesday, May 22, 2007

GUI, state machine, input, cursor

The base GUI helper class is basically complete and is ready for testing. However, the game isn't far enough along to test it yet, and I don't feel like taking the extra time to make a unit-test. Thus, I am now working on structuring the core game loop.

I'm creating a state machine that's a little cleaner than my last rendition. This time, each state has its own class, rather than all states being contained in one big class.

The input helper class is complete. I unit tested the mouse and keyboard input and they're working great, but I have yet to test the gamepad. The great part about the new input class is how customizable it is. For example, one player can have controls on multiple different inputs. The A button on gamepad 1 shoots and the B button on gamepad 2 jumps. Maybe shift on the keyboard runs. Heck, if I wanted to, I could assign one button to multiple players. I could even treat a control stick as a button. If it's moved in one direction a certain amount, it will be considered "pressed" like a button. This would work nicely for the triggers.

I unit tested the mouse with a new cursor class I made, which is working like a charm. It doesn't use the exact position of the OS's cursor. Instead, it has its own position and uses the movement of the OS's cursor to move. Also, it uses my input helper class, which means I can easily change what controls the cursor. For example, I could easily have the gamepad to control the cursor without much change to the code.

clevceo

No comments: