Game Design 2: Blogpost #1, Paralaxing backgrounds

For this blog post I will be writing about the code I have written for the looping paralaxing background in our game called Behemoth. My name is Jonathan Berggren, I am part of group Siren which is a group of students at Uppsala University, Campus Gotland. I am the only programmer in our group.

For our game we want to simulate movement of the ship by making the background continuously scroll to the left. The code that is used for this is quite simple, it works by moving the image to the left at a variable speed that is changed for each different background using the code, the speed is also multiplied with a built-in function called Time.fixedDeltaTime which makes sure that the speed is consistent even if the game runs at a different amount of frames per second. It then returns the image to its original position once it has fully scrolled past the screen. The image is also doubled with a second copy placed right after it so that there is no empty space after the right edge of the image has passed the right side of the screen but has not yet passed the left side of the screen. This same code is used on multiple layers of backgrounds with different speeds applied to them which creates a sort of paralax effect making the slower background appear to be further away than the faster moving ones. The ones in front are transparent so that the backgrounds behind it are visible which also makes it feel even more like glass or crystals to match with the ship and enemies in the game. The paralaxing created what I consider a very aesthetically pleasing look which cannot be properly expressed using a still image however the image bellow is a snapshot of what the game looks like in action using placeholder graphics. Later on this same code will be used for foreground images aswell, we plan to have clouds that will appear to be moving across the screen very close to it just behind the UI of the game in front of the ship and enemies.blog1

1 Comments

  1. Hello Jonathan! My name is Oscar and I’m the programmer for team Rakshasa. I’ll be the one commenting on your posts.You’re off to a good start with introducing yourself and the project your working on but I have some minor criticisms. For starters, your post is a little bit short and you don’t really go into that much detail. It’s very blunt. I know it’s hard to write long about your code but maybe a sentence or two on why you choose this particular method or something. Lastly, I think that it’s great that you have a picture to show what you’re talking about, although it would have been nice if you made some comment on it in your text. Something short like “as you can see in the picture below” would have been enough.

    Any questions or whatever just comment on this comment and I’ll hopefully see it. Cheers!

    Like

Leave a comment