| |||||||||||
|
Main Menu Other |
Tutorials -- Working with Objects | ||||||||||
|
Subclassing the BasicObject ClassCreating a subclass of our BasicObject class is simple. Lets make one for our player
class Player : public BasicObject {
public:
// angles
int ax, ay;
// movement according to angles, calculated with sin or cos
float mx, my, mz;
// update the mx, my, and mz according to the player's angle
// the sin and cos functions only work if you have #included
// "math.h" somewhere in your project
void UpdateDirection() {
mx = sin(ay * 0.0174532925) * cos(ax * 0.0174532925);
mz = cos(ay * 0.0174532925) * cos(ax * 0.0174532925);
my = sin(ax * 0.0174532925);
}
};
Now if we create an instance of the class Player, it will have every property of the BasicObject class, plus any properties we define specific to the Player class. That's all for now. I hope this has helped you rather than confused you. =]
|
|||||||||||