Technical Documentation
Program Description
Q-Blizzard paints a scene of different colored snow flakes falling onto a curved hill at the bottom of the screen. The snowflakes are part of a particle system that keeps track of several different properties for each snowflake particle, including speed, rotation, color, opacity, and randomization of each of these properties so it looks somewhat realistic. There is also a randomly generated terrain that the snow falls on at the bottom of the scene, which is generated from a b-spline curve. The b-spline curve acts as the top of the ‘hill’, and then triangles are generated in order to create a solid looking object.
The project was created using the XNA framework, which makes use of C# and the .NET 2.0 Framework. Much of the particle generation is hard-coded, such as where the snowflakes begin. Most of these constants are externalized into the file Constants.cs.
Historical Development of Program and Current Status
Releases:
- Mid-Term: Snow is falling, background texture is in place, and randomization of particles is in effect.
- Final: Terrain created and snow falls on the curve that is generated each execution.
Overall System/Program Structure
This diagram displays the key classes in Q-Blizzard along with their relationship to the XNA framework:
Description of Key Data Structures
I am going to use this to explain what each class does and how they interact.
- Program: Application entry point, starts up the XNA Framework Game (QBlizzard)
- QBlizzard: The Game class, the main workhorse of the application. This class sets up the GraphicsDevice, which determines the resolution of window as well as other properties such as multisampling. This also creates all of the relevant GameComponent classes, which XNA uses to render objects on the scene. It adds the GameComponents into the Game’s components collection at the initialization, which starts off the process of creating the scene.
- Particles/Snowblower: Manages the snowflake particle generation and death. This keeps track of every particle in the system, and adds/removes them from the rendering pipeline when necessary.
- Particles/Snowflake: The actual particle class. Before each particle falls, it generates a random set of properties for itself, such as how fast it will fall, where it starts, the tint, opacity, and wind speed. The movement of each particle is based on cos(), with randomizations for amplitude and jitter.The snowflake has 5 different states: Created, Falling, Fallen, Melting, Melted. Each snowflake starts as created, and can be put into the rendering pipeline by the Snowblower at this point. The Snowblower flips the state of the Snowflake to Falling, which starts the drawing and calculation of the snowflake. Once the snowflake hits the terrain, the Snowflake changes to Melting, where its alpha value decreases to zero. Once it is zero, the snowflake is Melted, the Snowblower can remove from the pipeline and get it ready to fall again.
- Scene/Background: Paints the background texture onto the scene, courtesy of VladStudio.
- Scene/Terrain: This class creates the hill at the bottom of the scene that snow falls on. Creating the curve randomly each execution of the program requires several steps. First of all, random knots are chosen between a certain range for the b-spline curve to use. Using 4 knots at a time, the curve vertices are found, and generation of vertices continue until the edge of the screen is reached. Once the curve has been generated, a triangle list is generated using the vertices of the curve and the bottom of the screen to create the illusion of a solid hill.The terrain also contains two important routines that the snowflakes query consistenly in order to fall on the curve. The first is the upper limit of the terrain, which the snowflakes first check in order to prevent the midly complex hit testing happening on every update, of every snowflake, for every y-value. If this first test passes, then the snowflakes can check if they’ve hit the y-value of the line segment of the curve that matches their current x-value. If so, the snowflakes know to stop, and they fall nicely on the curve.
- Common: Contains the function that generates the b-spline, which I externalized from the Terrain code mostly in hopes that it would be reused at some point.
- Constants: Values used throughout the program that control resolution, wind speed, melting time, random generation limits, particle spawning rate, and much more.
Built-in Maintenance Aids
None that I can think of, the Visual Studio debugger usually takes care of the need for any of these.
Other
This project was created in Visual Studio 2005 with the XNA framework. This will require that XNA Game Studio 2.0 is installed, located here. From there, unzip and open Q-Blizzard.sln in Visual Studio and you should be set.

Comments are closed.