This is an overview of the code that is in scene1.c.
// GAME LOGIC //
if (initializeDrawScene1)
{
The code within this if statement is only executed once
and will not executed again even if scene1 has restarted.
initializeDrawScene1 = 0;
}
if (resetDrawScene)
{
The code within this if statement is
executed every time scene1 is restarted.
resetDrawScene = 0;
}
// return global and transformation data back to its original state
// this will keep rounding errors from deforming the meshes
This is where meshes are put back to there original states as if they have not moved at all. This means their orientations have to be recalculated for each frame.
// After changing the course's orientation its x's and y's
// will no longer be aligned horizontally and vertically.
// So position objects before this point because it might be harder
// to position them once the course's orientation has changed.
This is were the course moves to the position where it left off. This means the character is placed in the right position on the course.
// Temporarily rotate the course so that its
// x's and y's are aligned horizontally and vertically.
// Keep the rotation data to return the course back
// to its normal rotation.
The course's orientation has changed so that its x's and y's are aligned horizontally and vertically just like before except the character keeps its position relative to the course this time.
// If the character falls or jumps this changes the z
// position of the course and if you have objects placed on
// the course this is the place to change the z positions
// of those objects to keep them with the course.
After this point the characters z position is correctly calculated after falling or jumping.
// return the course back to its normal rotation
The course's orientation is put back to where it needs to be for rendering.
// DRAW //
// fill z-index buffer
for (y = 0; y < rI.yWin; y++)
for (x = 0; x < rI.xWin; x++)
rI.zIndex[x][y] = rI.camEndZ;
Anything less than rI.camEndZ will not be drawn.
// color background
for (y = 0; y < rI.yWin; y++)
for (x = 0; x < rI.xWin; x++)
rI.scrnBuff[x][y] = bgColor;
bgColor is painted to the screen.
addRotLocSz(mesh_TRANS, mesh_POINT, mesh_POINTDATSZ,
mesh_STATICPOINT, mesh_MESHCNT);
This function applies the transformation data to the vertices.
addScreenRotLocSz(xScreenRot, yScreenRot, zScreenRot,
xScreenSize, yScreenSize, zScreenSize,
xScreenLoc, yScreenLoc, zScreenLoc,
mesh_POINT, mesh_POINTDATSZ, mesh_MESHCNT);
This function changes the orientation of the vertices again.
drawMesh(mesh_POINT, mesh_LINE, mesh_COLOR,
mesh_LINEDATSZ, mesh_MESHCNT, bgColor, antialiasing, rI);
This function draws a mesh.