Game Development Reference
In-Depth Information
The _hasFloated property will ensure the player can only open the umbrella
once while in the air. And when we set _floating to true , we give the
_player.y vector a boost.
3. We begin the update method of _player with:
void Player::update (float dt) {
if (_speed + P_ACCELERATION <= _maxSpeed) {
_speed += P_ACCELERATION;
} else {
_speed = _maxSpeed;
}
_vector.x = _speed;
The game will increase _maxSpeed of the _player object as time goes on,
making the game more difficult. These first lines make the change from the
_players current _speed up to _maxSpeed a bit smoother and not an imme-
diate change.
Note
Victorian Rush Hour has no levels, so it's important to figure out a way to make it
incrementally harder to play, and yet not impossible. Finding that sweet spot in
your logic may take some time and it's one more reason to test game ideas as soon
as possible. Here we make the game harder by increasing the player's speed and
the size of the gaps between buildings. These are updated inside a countdown in
the main loop.
4. Next, we update the _player object based on its _state of movement:
switch (_state) {
case kPlayerMoving:
_vector.y -= FORCE_GRAVITY;
if (_hasFloated) _hasFloated = false;
break;
case kPlayerFalling:
if (_floating ) {
Search WWH ::




Custom Search