Game Development Reference
In-Depth Information
That is all the vector operations needed. With this simple structure a whole 3D
world can be built and manipulated. Don't worry if you don't quite understand
every little bit at the moment; the more you use the bits you do know the more
the rest will fall into place.
Two-Dimensional Intersection
Intersection is a way of determining when two shapes overlap or intersect. This is
essential in all graphical programming including games. Detecting if the mouse
cursor is over a button is an intersection test. In games, detecting if a missile has
hit a ship is also an intersection test. 2D intersection is very simple and a great
place to start.
Circles
Circles are defined with a position and a radius. Intersection is best shown gra-
phically, so let's create a new game state called CircleIntersectionState
and make it load by default.
class CircleIntersectionState : IGameObject
{
public CircleIntersectionState()
{
Gl.glLineWidth(3);
Gl.glDisable(Gl.GL_TEXTURE_2D);
}
#region IGameObject Members
public void Update(double elapsedTime)
{
}
public void Render()
{
}
#endregion
}
The state currently does nothing apart from getting OpenGL ready to draw lines.
Next, a circle class needs to be created.
 
 
Search WWH ::




Custom Search