Team 12 Game Development Artifact 2 – Background looping
|
Alpha is upon us! In two day Team 12 will present Heartbeat bat in it’s alpha state. The game is going to be a mix between speed runners adm super mario kart, the player is in a flying state. To progress through the level the player needs to avoid multiple objects at a high speed and to reach the end of the level in a short time. During this week I worked on creating a looping background for our game Heartbeat Bat, I will go into detail on the What, the how and the why. What is it ? The looping background artifact is consisted of two identical backgrounds, left background and right background. The left background is the starting background and the right background is placed right next to it ready to be displayed when the game camera moves. When the player reaches the backgound middle point, the game switches the previous background and place it in ahead of the player behind the gameview. Each background is big enough to cover 10 screens of width 1080p and they were drawn in a way that they will always blend with each other, leaving no possibility for any distortion. How ? I used a very simple method of switching between the backgrounds when they are needed. The trick was to use a an infinite loop that switches the x positions of the backgrounds. moving them in and out the viewport(camera) of the game with the help of a trigger. The trigger executes when the player x position is bigger or equal to the current background x position + half the width of the background. When that condition is true, the previous background will be placed ahead of the current background behind the scen(camera). Why ? At the start of the project we drew multiple backgrounds at the same time at different positions, which was problematic, for many reasons. The backgrounds are 10000 pixels wide and are about 4 megabyte each, placing several of these backgrounds slowed the game down. The other reason was when the player flew by the end of the backgrounds, the backgrounds was still been drawn outside the camera which was a waste of resources. We chose to switch the backgrounds infinitely because we did not have a fixed length for each level, so this method could be reused again for the other levels with different lengths. Top stop the infinite loop we use a timer to stop the game. |
