Game Development Reference
In-Depth Information
void Enemy::Load()
{
LoadTexture(std::wstring(L"textures\\enemy.DDS"));
_sprite->Rotation = -XM_PIDIV2;
}
This is much simpler, but we will be specifying the position of the enemy at a later
point, so we don't need to worry about that for now.
Also note the rotation lines for both the Player and Enemy . If you take a look at the
provided art assets you'll see that both ships point upwards and, if rendered without
change, you'll have both ships pointing up instead of towards each other as they
should. Here we're just telling the sprite that it needs to be rotated by 90 degrees and
-90 degrees for the player and enemy, respectively. We do this by using the radian
representation of the angle, which you'll find is common in game development. For
reference, the conversion between radians and degrees can be done with the follow-
ing formulae:
In a lot of cases just remembering that 180 degrees is equal to π radians will be
enough, as it is here, where to get 90 degrees we can just say π/2 radians, which is
the equivalent of 180/2 degrees.
We'll leave the Player->BindInput method alone for now because that will re-
quire the addition of input code, and instead look at the enemy movement. In this
game the enemies will be moving from right to left at a constant rate of speed. If you
look back at the Ship definition, we have a helper method called Move , which allows
us to specify a direction and the time since the last frame. This method when imple-
mented will use the _speed property of the Ship to move the object in the speci-
fied direction, relative to the amount of time since we last updated. Pretty simple! So
Search WWH ::




Custom Search