Game Engine Architecture

(Ben Green) #1

128 3. Fundamentals of Software Engineering for Games


// do additional work specific to Triangles...
}

private:
Vector3 m_vtx[3];
};

// -----------------------------
void main(int, char**)
{
Shape* pShape1 = new Circle;
Shape* pShape2 = new Triangle;

// ...

pShape1->Draw();
pShape2->Draw();

// ...
}

3.3 Catching and Handling Errors


There are a number of ways to catch and handle error conditions in a game
engine. As a game programmer, it’s important to understand these diff erent
mechanisms, their pros and cons, and when to use each one.

3.3.1. Types of Errors

In any soft ware project there are two basic kinds of error conditions: user er-
rors and programmer errors. A user error occurs when the user of the program
does something incorrect, such as typing an invalid input, att empting to open
a fi le that does not exist, etc. A programmer error is the result of a bug in the
code itself. Although it may be triggered by something the user has done, the
essence of a programmer error is that the problem could have been avoided if
the programmer had not made a mistake, and the user has a reasonable expec-
tation that the program should have handled the situation gracefully.
Of course, the defi nition of “user” changes depending on context. In the
context of a game project, user errors can be roughly divided into two catego-
ries: errors caused by the person playing the game and errors caused by the
people who are making the game during development. It is important to keep
track of which type of user is aff ected by a particular error and handle the er-
ror appropriately.
Free download pdf