Screen Scrolling, one way to do it.

Hello there!

Now as we are four weeks in on our second game project I would like to talk about one of the (unfortunately few) things I have currently been working on during this past week. With a lot of help from my co programmer we have manged a way of smoothly moving the view across the screen and preventing the player from moving backwards. Constantly forcing the player to progress forward through our level with no option of going back to a previous location on the level.

Screen Scrolling

(The white mark indicates when the game should start moving towards to right and hence given the game a scrolling view.)

Screen Scrolling 2

(Do not worry, the white box while not be displayed during the game play, it stays hidden but works as intended.)

Now I should perhaps being with explaining  what project we are working on to what purposes we are creating this game. In our previous Game Design Course we was told to make a concept on a space shooting game based on towards and set with some requirements and limitations. Now as we began our current course our teams from before would choose another teams concept and create a fully functional game based on their concept.

But back to the topic at hand. Before we manged this solution we had a bit of trouble with the screen ”running” away from us or it being the other way around and the player ran out from the screen. This was due to that we set the cameras to move every time I pressed our walk key and alto this worked well for first seconds it quickly stared to move in a speed not matching the players. Which lead the view to outrun the player or vice verse. One idea was to give the camera a consistent speed from the beginning of the game and making it´s speed slightly slower compared to the players. This was never tried for as  it would not match the concept for this game.

We are making a fast paced game where you as the player races against the clock and at the same time you need to gather enough points to clear each level before the time runs out. What if the player would miss points somewhere because they needed to dodge an enemy or run around an obstacle due to low life and when the time run out have not gathered enough points. So it was back to the drawing table and a possibility to lock the camera onto the player itself was formed, now it would never be able to outrun us and we could set the pace our selves guaranteeing that our player would be able to gather point all along the way.

What not occurred was two things. Firstly the scrolling partly worked as intended but secondly we could move backwards as well, which was not one of the things we wanted to be able to. So by attaching the camera to a new object  and place it across the screen (the white box displayed above). And set the player to collide with this new object and while there is collision the camera are moving with the same speed as the player. The player gains a speed boost so does the camera and when there is no collision the camera stands still and we can freely move around in the space behind it. To stop the player from moving to far backwards and ending up outside the screen another box was placed just outside the screen that moves with the same speed as the camera box with a collision to it which stops the player the player is forced to move forwards by pushing our invisible box whiled limited to move freely in the space between these two boxes.

This is all for this week and at the end of next i will be back presenting next weeks major artifact. So until then i wish you a good weekend and a happy valentines day.

About David Eliasson

2014  Programming