Game Development Reference
In-Depth Information
Obstacles[i].vPosition.y = GetRandomNumber(_GROUND_PLANE +
_OBSTACLE_RADIUS, _WINHEIGHT/2 −
_OBSTACLE_RADIUS*4, false);
Obstacles[i].fRadius = _OBSTACLE_RADIUS;
Obstacles[i].fMass = 100;
}
.
.
.
}
Drawing the obstacles is easy since they are Particle types with a Draw method that
already draws circular shapes. We created DrawObstacles to iterate through the Obsta
cles array, calling the Draw method of each obstacle.
void DrawObstacles(void)
{
int i;
for(i=0; i<_NUM_OBSTACLES; i++)
{
Obstacles[i].Draw();
}
}
DrawObstacles is then called from UpdateSimulation :
void UpdateSimulation(void)
{
.
.
.
// initialize the back buffer
if(FrameCounter >= _RENDER_FRAME_COUNT)
{
ClearBackBuffer();
// Draw ground plane
DrawLine(0, _WINHEIGHT - _GROUND_PLANE,
_WINWIDTH, _WINHEIGHT - _GROUND_PLANE,
3, RGB(0,0,0));
DrawObstacles();
}
.
.
.
}
Search Nedrilad ::




Custom Search