2014-02-12 – An artifact
|
The end of this project is drawing closer and we are all starting to see some result from our hard work – gamewise as well as learningwise. One of my tasks has been to create a code for the paralax function which will consist of a couple of layers of mountains or hills disappearing in the horizon, a story box and clouds. As soon as I figured out how to work with the paralax and different layers it was pretty easy to continue, but one artifact within the paralax differed itself from the other ones – the clouds. What function would the clouds contribute with to the game? What would the player experience? In order to create the clouds I used one cloud-sprite that is as wide as the gamescreen. They do not have an animation but are just a simple sprite. I made them spawn at the coordinates (0,0) in the game, and am only changing their x-coordinate throughout the game by -=0.05 in order to create the slow movement from the right to the left. When they have completely disappeared from our view to the left (when the cloud x coordinate is less than the camera x-coordinate minus 512) I made them jump to the camera x-coordinate + 512, making them always cycle around what the player actually sees in the game rather than the entire gamearea in order to create a consistant and smooth flow between the despawn and respawn. Since the player (or rather the player’s field of view) will move around either to the right or to the left I made the clouds x-position adapt to the cameras x-position, meaning that the cloud movement will slow down a bit while the player is moving to the right and speed up a bit when moving to the left. All of this in order to create a realistic feeling when the player is moving. Last but not least I added one additional cloud-sprite that had the exact same texture as the first one and the exact same code except from the x-coordinate on which it is drawn in the first place. This cloud-sprite starts off where the end of the first cloud sprite is in the beginning, which means that there will always be clouds on the sky even if one of the sprites has just ended its cycle across the screen and is currently on its way back in from the right.
|

