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).

blog_2

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.

One thought on “Team 12 Game Development Artifact 2 – Background looping

  1. I’d say that your blog is very straight forward, which is good. You have structured your post with an introduction, and then you explain the three requirements of the blog post underneath separate headlines. You explained what it all was very well by explaining that there is two identical backgrounds that is continuously placed in front of each other. Then you tell us how by explaining how the code activates and its condition. I am no programmer which is why I probably get a bit confused at this part. But as how I understood it the code is triggered when the player sprite reach the middle of the current background. To simplify it for a non-programmer you could have added that to the end, but I don’t think that should be that necessary. If I did understand it right it is right!

    Moving on you continued to explain why your group decided to use an infinite loop of the same background instead of having variations. It is a very good decision when this is our first game, also there wouldn’t be much other choice since it is a game that can continue ever on. Anyway I would say that there is not anything missing in this post. It is very straight forward. Good job!

    Like

Leave a comment