Im trying to get inheritance working but idk how, i want to know how to use the base class's constructor in the class that inheritits it, but also let the class that inheritits it have its own constructor, but idk how, heres my code so far:
t_entity.h:
#ifndef __t_entity
#define __t_entity
#include "DarkGDK.h"
class t_entity {
int id;
float posX;
float posY;
float posZ;
float rotX;
float rotY;
float rotZ;
public:
t_entity(int iID, float p_fX, float p_fY, float p_fZ,
float r_fX, float r_fY, float r_fZ, LPSTR lpFileName);
~t_entity(void);
// Modifying Functions
void Position(float fX, float fY, float fZ);
void Rotate(float fX, float fY, float fZ);
void Move(float iSpeed);
// Position Access Functions
float PositionX(void){ return posX; }
float PositionY(void){ return posY; }
float PositionZ(void){ return posZ; }
// Rotation Access Functions
float RotationX(void){ return rotX; }
float RotationY(void){ return rotY; }
float RotationZ(void){ return rotZ; }
//animations
void LoadAnimation(LPSTR lpAnimationFileName, int iFrame);
void PlayAnimation(int iSpeed);
void PlayAnimation(int iStart, int iSpeed);
void PlayAnimation(int iStart, int iEnd, int iSpeed);
void LoopAnimation(int iSpeed);
void LoopAnimation(int iStart, int iSpeed);
void LoopAnimation(int iStart, int iEnd, int iSpeed);
};
#endif
t_entity.cpp:
#include "DarkGDK.h"
#include "t_entity.h"
t_entity::t_entity(int iID, float p_fX, float p_fY, float p_fZ,
float r_fX, float r_fY, float r_fZ, LPSTR lpFileName)
:id(iID)
{
posX = p_fX;
posY = p_fY;
posZ = p_fZ;
rotX = r_fX;
rotY = r_fY;
rotZ = r_fZ;
dbSetDir("Media");
dbLoadObject(lpFileName, id);
dbPositionObject(id, posX, posY, posZ);
dbRotateObject(id, rotX, rotY, rotZ);
}
t_entity::~t_entity(void)
{
dbDeleteObject(id);
}
void t_entity::Position(float fX, float fY, float fZ)
{
dbPositionObject(id, fX, fZ, fY);
posX = dbObjectPositionX(id);
posY = dbObjectPositionY(id);
posZ = dbObjectPositionZ(id);
}
void t_entity::Rotate(float fX, float fY, float fZ)
{
dbRotateObject(id, fX, fY, fZ);
rotX = dbObjectAngleX(id);
rotY = dbObjectAngleY(id);
rotX = dbObjectAngleZ(id);
}
void t_entity::Move(float fSpeed)
{
dbMoveObject(id, fSpeed);
posX = dbObjectPositionX(id);
posY = dbObjectPositionY(id);
posZ = dbObjectPositionZ(id);
}
void t_entity::LoadAnimation(LPSTR lpAnimationFileName, int iFrame)
{
dbAppendObject(lpAnimationFileName, id, iFrame);
}
void t_entity::PlayAnimation(int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id);
}
void t_entity::PlayAnimation(int iStart, int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id, iStart);
}
void t_entity::PlayAnimation(int iStart, int iEnd, int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id, iStart, iEnd);
}
void t_entity::LoopAnimation(int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id);
dbLoopObject(id);
}
void t_entity::LoopAnimation(int iStart, int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id, iStart);
dbLoopObject(id, iStart);
}
void t_entity::LoopAnimation(int iStart, int iEnd, int iSpeed)
{
dbSetObjectSpeed(id, iSpeed);
dbPlayObject(id, iStart, iEnd);
dbLoopObject(id, iStart, iEnd);
}
US_Soldier.h:
#include "t_entity.h"
class US_Soldier : public t_entity {
int health;
int ammo;
public:
//US_Soldier(int health, int ammo);
};
US_Soldier.cpp:
#include "us_soldier.h"
US_Soldier::US_Soldier(int health, int ammo)
:health(health), ammo(ammo)
{
t_entity(
1,
0, 0, 0,
0, 0, 0,
"USA\H-USA-Static.x"
);
LoadAnimation(
"USA\H-USA-Idle.x",
10
);
LoopAnimation(1);
}
Any help would be greatly appreciated