Trowl – HardWinds

This week I have been working on serveral different tasks. Amongst these were: Owlet duplication and movement, two different enemy-type classes (Eagle and Hawk) and finally Hard winds. I have choosen to describe more thoroughly is how I implemented Hard winds into the game.

Hard winds is one of our obstacles in  Trowl. If the player enters these hardwinds the player movement is slowed down for a couple of seconds causing him and the owlets to become more vulnerable to enemy attacks.

HardWindsblogg

This is how hard winds look like in the game. Luckily the sprite which represents hardwinds is just a temporary one that I have created and will not be in the final version of the game.

Functions and calculations

To make this obstacle I created a new class with no special functions except the one function that makes the sprite appear in the game every 30 seconds. I declared this function in the Hard winds class update function which counts frames/second.  The function includes three float variables: one for elapsed time,  one for duration and one for frames/second. Elapsed time is in this case equal to frames/second and duration is a constant variable which I have set to  30. When elapsed time is equal with duration the hard winds sprite loads into the game. So, from the point when the player starts the game the counting of frames/second starts until it reaches 30 and the hard winds event is initialized. The duration of the event is 10 seconds and to do this I created a function that takes elapsed time subtracted with duration when 10 seconds have surpassed the 30 second mark.These are the complete list of functions:

  • [ElapsedTime += Frames/Second] (Just to count seconds in the game)
  • [ElapsedTime >= Duration] (When this occurs, hardwinds event initializes)
  • [ElapsedTime >= Duration + 10](Event duration is 10 seconds and when 10 seconds surpasses the duration, hardwinds event stops.)

Besides these calculations the hard winds class is basically just a big collision box that checks collision with the player. When the player collides with hardwinds the friction value of the player is increased. The friction value regulates the players speed and mobility and therefore kind of creates the sensation of flying in hard winds.

This obstacle was implemented in the game to create a more interesting gameplay and challenge the player by making positioning a more vital part of the gameplay. At least two other obstacles will be implemented but this is the first one that will be shown in our Alpha.

 

Leave a comment