Game Development Reference
In-Depth Information
DirectX::XMFLOAT2 GetTextureSize();
};
The code for
Player.h
is as follows:
class Player :
public Ship
{
public:
Player(void);
~Player(void);
void Load();
void BindInput(float screenHeight);
void Update(float deltaTime);
};
Here you can see the class definitions for both. The ship will serve as our common
base class for both the
Player
and the
Enemy
. It will contain some basic information
such as the position and rotation, as well as (in future) the texture of the ship. Along-
side that we also have the health of the ship, which will be monitored by the base
class.
Inside the
Ship
class, we have some helper methods to handle loading the sprite
and managing the lifetime of the object, which we will put to use later on. We won't
define the visual code for the
Ship
yet as we will handle that when we get to the
rendering system later on.
Inside our
Game
class, let's start by adding a pointer to a Player object, and new
that up inside
LoadContent
. At the same time let's call
player->Load()
and
BindInput
as follows.
_player = new Player();
_player->BindInput(m_renderTargetSize.Height);
_player->Load();