Author Topic: 2D Screen Scrolling  (Read 1714 times)

david

  • Guest
2D Screen Scrolling
« on: 2008-Mar-02 »
Hi, I am currently making a 2d game and was wondering how you make the screen scroll? I mean like your character stays in the same place, but the background scrolls around where you are moving. Like in the sample game, mario, the background moves. How do you do that?

Thanks,

David

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
2D Screen Scrolling
« Reply #1 on: 2008-Mar-02 »
For the most efficient method of scrolling a background stage, then you're going to have to look into tiles and tile engines. These are useful for all games, not just for scrolling games.

Tiles are individual blocks of images (like pieces of a jigsaw puzzle) that when placed together form an image. You'll then need an engine to place all of your tiles into a specific order and scroll as necessary.

Tile engines are actually very easy to create, although for someone who's never used one, then they can be quite challenging.

There are various tile engines that you can borrow from other languages and adapt to your own needs, but again this requires some knowledge of exactly how they work.

A good freeware map editor (this allows you to load in your own tiles and then place them into your level is Mappy) and as luck would have it, Moru has created a Mappy loader for GLBasic that should allow you to import any maps into your game, ready for use - http://www.glbasic.com/forum/viewtopic.php?id=1633
I came. I saw. I played.

Offline PeeJay

  • Mr. Polyvector
  • ***
  • Posts: 244
    • View Profile
    • PeeJays Remakes
2D Screen Scrolling
« Reply #2 on: 2008-Mar-02 »
Good advice there from Ian

The only thing I can offer it a more general look at how it works.

Normally you would have a character moving around a screen, with co-ordinates stored in x and y.

If we want the background to move instead, we lock the player in position, and move the background by -x and -y. In other words, the background moves in the opposite direction to your player (since your player position is now fixed)

Good luck, and don't be afraid to ask questions ;)
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity