Game Development Reference
In-Depth Information
This will trigger our methods to set up the graphics and input code that we will add in
later on when we reach those respective systems.
We added a Ship base class for a reason. Even though they oppose each other, the
player and the enemies are both common in many ways. Why repeat code when the
only real difference is the logic behind the control of each ship?
Add in an Enemy class and give it the following definition:
class Enemy :
public Ship
{
public:
Enemy(void);
~Enemy(void);
void Load();
void Update(float deltaTime);
};
You can see this is pretty similar to the Player class but, as we don't need to control
the enemy, we don't need a method to set up the input system. Now let's take a look
at the implementation of the Load method for both of these objects. Here we'll use
the LoadTexture helper defined in Ship to load in the right texture for each type of
object. For the player, we want to add the following call:
void Player::Load()
{
LoadTexture(std::wstring(L"textures\\player.DDS"));
_sprite->Rotation = XM_PIDIV2;
auto texSize = _sprite->GetSize();
MoveTo(
_position.x + (texSize.x / 2.0f),
_position.y + (texSize.y / 2.0f));
}
Search WWH ::




Custom Search