Game Development Reference
In-Depth Information
think of a vector as a line that is one unit of length long. The line described here is
1 on the Y axis, so it's a straight line along the Y axis. Imagine this line pushed
through the center of the triangle, passing from the point at the top through the
middle of its wide base. Rotating the line then rotates the entire triangle. Try to
visualize how the triangle would rotate with the arguments (1, 0, 0) and (0, 0, 1),
then amend the program to check if you were correct.
The first argument, the angle in degrees, is being multiplied by the elapsed time.
This is to ensure time-independent movement and should make the animation
smoother. If the program is playing at 60 frames per second, that means each
elapsed frame time will be around 0.1 seconds. This means to move the triangle
10 degrees will take 1 second. If someone else runs your program on a slower
computer, and it can only go, say, 30 frames per second, then each frame will
take about 0.2 seconds to complete. There are fewer frames per second but the
triangle will take the same amount of time to rotate on both machines. If the
degrees were not multiplied by the elapsed time, then the program would run
twice as fast on the machine that runs at 60 frames per second.
Summary
Most games have a central loop that checks the player input, updates the game
world, and then updates the screen. By default, C# does not have a central loop
so some C functions need to be used to create a fast game loop useful for creating
games. Additional C functions are used to get access to timing information so
each frame can be timed. This time can be used to ensure the game runs
smoothly, even on computers that run at different speeds.
The Tao framework library has a control called SimpleOpenGLControl . This
control allows OpenGL to be used easily within a Windows Form. A spinning
triangle is often used as the ''Hello World'' program for OpenGL. The triangle is
made up of three vertices and each can be assigned a different color. If the
vertices of a triangle are different colors, the triangle's pixels will be colored
according to the distance from each vertex. OpenGL has a function called
glRotated , which takes care of the final task of rotating the triangle.
 
 
Search WWH ::




Custom Search