The other day, I was thinking to myself, “I’m a very experienced programmer, I’m very creative, and I like video games; I should try making some computer games.” It seemed like such a no-duh sort of thing, I don’t know why it didn’t occur to me until recently. I used to make text games out of BASIC when I was a little kid and dreamed of making more complex games, but it just hadn’t occurred to me to revisit that — perhaps because my focus had been more hardware than software until recently.
Anyway, I found out that Microsoft has this XNA library for game creation that uses C# and Visual Studios — what I use at work now so no learning curve on the programming basics. Apparently, Microsoft is making this excellent library available for free to try and get game programmers to use managed code. Now, I would have laughed at the idea not too long ago (“Managed code for a computer game? Yeah, if I want it to run at three frames per second!”), but I’ve now done quite a lot with C# (most of my experience had been with regular old C) that I would have thought would be impossible without pointers, such as dynamically creating and populating an instance of a class. So I’m a C# convert and excited to make games.
I start with the tutorials, which are nice but a little annoying since they assume you’ve never even programmed before (and I don’t see you getting very far with XNA without some basic programming experience). I find the logical flow of XNA pretty easy to understand and easy to play around with. The hard part I find out when fiddling around with the 2D tutorial is the math. I had to go back to basic geometry and try and remember how to use Sin and Cos to get the length of sides on a right angle. Nothing too bad, though.
So I move on to the 3D tutorial. Quite a bit more complicated, but I think I can still understand it all. Now I want to add mouse support to the game. My idea is to add a crosshair sprite, come up with a 3D point in the distance that corresponds with where the 2D crosshair is on the viewport, and aim the cannon at the point. I decide to start with aiming the 3D cannon by seeing if I can program it to track one of the enemy ships.
Holy crap.
First of all, when working with objects in 3D space, the simplest thing to do is use matrices so you can adjust the whole 3D object uniformly. Simplest does not mean simple, though, as I still don’t have any concept of the where and why of the matrices. I do know matrix algebra from rote, but I never got a conceptual understanding of it (didn’t think I needed one). The other problem is rotation.
I found this help on getting a 3D object to point at another. That worked on getting the cannon to rotate on just the y-axis, but I’m still trying to figure out how to get it to rotate to follow a ship on both the y and x axises without distorting the cannon. Not simple. I keep running into quaternions to represent rotation, but the consensus on those is just learn how to use them and don’t even attempt to understand them.
Now, I’ve actually worked before with complex math involving 3-dimensional points transformed with matrices when I figured out how to do elliptic curve encryption on hardware (does anyone use that? It is much faster — though much more complex — than RSA — especially on hardware since in certain configuration an XOR is used for addition (i.e., no carry bits) making for some relatively simple large multiplies). I never really understood it, though, as my engineering attitude is get the results you want and worrying about understanding what you’re doing secondarily. I never actually saw elliptic curve as representing points on a 3D plane but instead just a bunch of weird math I did to get the required output.
Anywho, that’s my new hobby I’m up to. Don’t know if any of you could be of help. Maybe I should stick to figuring out a simple 2D game to make as a starter project, but it would be nice to know some basics in making 3D games.