How to create a simple side scroller game

D34thSt4lker picture D34thSt4lker · Sep 16, 2012 · Viewed 8.5k times · Source

I'm still pretty new to game programming and any tutorial that I have worked with stuck to only games with the initial screen. I want to start creating my own games but there are a few things that I still need to learn. One of them is how to create a game that side-scrolls. For example; Mario... Or ANY type of game like that...

Can anyone give me a small example to create something like that. I'm not asking for any specific language because currently in school I am learning javascript but I know some c++/java/processing/objective-c as well. So any of those languages would be fine and I could probably implement it in any of the others...

I have been searching for some help with this for a while now but could never actually get any help on it.

Thanks in advance!

Answer

CBass picture CBass · Sep 17, 2012

Regardless of the programming language you choose, and whether you choose to use any higher level graphics, or even a game programming library, a fundamental technique you need to learn is creating the illusion of side movement. As pointed out, this can be achieved by drawing your avatar at screen center and then moving the image behind it. That can be accomplished in different ways, such as rendering and clipping different parts of a larger image, or if you are using a graphics/game library involving camera objects, dynamically controlling the portion being rendered by the camera.

Is your goal here to learn game programming, or are you just learning programming and briefly looking at game programming? If the former, than you really should invest the time to learn one or more game programming technologies. I would recommend you take a look at Unity, which is free to download and try out. The scripting language Unity uses is essentially javascript (you can also use C#), so you'll already be comfortable. Go through some of the tutorials and you'll be off and running in no time.

Note using technologies like Unity (and others) let you create game objects that move through two and three dimensional space, and which are rendered based on one or more cameras. Your backgrounds (or terrains in a 3d world) remain fixed, which more closely reflects the reality we live in. So mentally it is actually easier to develop using these technologies, then faking it through illusory techniques.