Programming tid bits

 

Engine

Since XNA is not an engine but a frame work I had to make all that stuff by scratch. The design I went for was like what a finite state machine is, a series of states that link each other and inherit off a base class. So I made a game state class which has everything a section of the game needs; initialize, load content, update, draw, and destroy. From there I created classes that would be run so I filled in this information for each part of the game, main menu, options etc. When the game is running it is running the base class, and the game then switches classes that it is running, I can do this since every game state class comes from the same state class. This provides me with a stable and flexible work environment where I can just worry about one section of the game and not have to worry if it will plug in or not.

 

Color Mixing

Part of this project was to get an accurate math based color mixing formula. Well let me say it is not easy, and still needs a lot of work but here is the gist of it. XNA works with RGB, paint however uses the CYMK model to do color. First off I had to create a translation, following pseudo code/math on the subject I created a c#/XNA based translator that will take in a rgb value, mix it, and then spit back out a XNA.color object (just an object that holds a RGB value).

 

Canvas overlay

In the game the particles will display a canvas like texture to them, this is simulating that they are being applied on the canvas. The solution was simple but effective, XNA lets you do things called blend states, I simply drew an image of a canvas ( with transparencies ) with the Additive blend state. Now the colors will look like they are popping out at you while also discoloring the canvas.