To keep things simple, I played around with re-creating what I could remember of a game I wrote long ago for text-mode BASIC, called “The Pit”. Didn’t get too far on that goal, but it kept me from being totally aimless. And in fairly short order, not only did I have a little stick-figure guy sliding smoothly across the screen in response to left and right cursor keys, I also had him plummeting to his doom whenever he walked off a cliff. Good times.
But since I was just playing, I was hacking all the game logic into the GUI. Decent way to get a feel for things, but not sustainable. And I got tired of always having to convert my in-game coordinates (1.0 = one tile) to screen coordinates (40 “pixels” = one tile) and back, and of having to track the horizontal and vertical coordinates in totally different ways (due to the way my game’s scrolling works), and of trying to keep my data model of “which tiles are obstacles” in sync with the GUI.
So that’s when I decided I would databind my video game.
Only makes sense, doesn’t it? Keep the player’s coordinates in logical scale, maintain them in one place, and have the databinding automatically handle the multiplying by 40 and the different rules for horizontal vs vertical scrolling. Add tiles to the Map data-model object and have them automatically appear on the screen. Databind the visual effects, like automatically showing the air-friction fireball when the player starts falling too fast. And I could even write unit tests for all the game logic. (Theoretically, anyway. How do you unit-test DoubleAnimation?)
But I can use WPF animation to move a stick figure across the screen. I should be good to go.
I’ve got some stuff working. Learned some things by doing them the wrong way around, getting stuck, and eventually simplifying. And now I’m going to start blogging about some of it. Stay tuned.