Sidescrolling Platformer ~Part 7~ Keys and Doors

First, I’d like to apologize for my brief hiatus over the past month — I upgraded to a new computer, and Flash was out of commission for a while. But assuming you haven’t abandoned this site yet, here’s the next part of the side scrolling series.

Last tutorial pretty much finished up the bare-bone mechanics and visuals of a basic platformer. So I figured with this tutorial we’d start adding various extra features to spice up the game. This time, we’re adding a collectible key to the level, as well as a locked door which it will open. This door might be the end of one of your levels, which in turn might load a new level afterwards (although we aren’t coding multiple levels in this tutorial — just the door and key which will allow for this in the future).

Make sure you’ve read up through Part 6 of the series.

Continue reading

Sidescrolling Platformer ~Part 6~ Parallax Scrolling and Multi-Layer Visuals

Welcome to the sixth installment of the AS3 Side Scrolling Platformer tutorial series.

The background scrolls. The player collides with walls, and can jump (and even double jump). Our laws of physics have been established, and the basic mechanics are coded. In other words, we have built a working prototype. In this tutorial, we will step our platformer up a notch by adding in fancier visuals, and even the capability for layers of parallax scrolling, which will give the game the sense of depth which it is lacking.

This is a pretty good tutorial, which will really improve your game if you’ve been following along. When all is said and done, this is what we will accomplish:

(click to activate, and control with the arrow keys)

Continue reading for a step-by-step guide on making this game

Sidescrolling Platformer ~Part 5~ Double Jumping

I know, in Part 4 I promised to cover the fancy visuals and parallax scrolling next, but here’s one more nifty game mechanic I wanted to add in first. (It’s quick.)

Double Jumping! Perhaps the greatest — most unrealistic — most lovable game mechanic ever.

This isn’t necessary for all games, and maybe you don’t want to add double jumping to your platformer game. But if you do want to add it, all that it requires is a bit of logic and a couple of Boolean variables. Plus, it will allow you to design cooler environments because the player will be able to reach more places than before.

This is what it will look like:

(Click on the preview below to activate it, then use the arrow keys to move around. Press the up arrow twice to double jump.)

Continue reading

Sidescrolling Platformer ~Part 4~ Gravity and Jumping

In Part 3 we took a simple, scrollable background and added a layer of realistic player interaction by adding collisions and smoother movement. But we didn’t have the time to finish our player interaction by adding gravity and jumping, so that’s what we’ll do in this part. We are also going to add a few small tweaks to earlier game mechanics so that everything runs better.

Get ready for another great tutorial. I put more time into this one than I expected to.

Gravity

Adding gravity is actually really easy. If you have any experience with Physics, you know that gravity causes an acceleration on objects. And an acceleration is nothing more than a change in speed. In an ideal situation on earth, an object’s velocity downwards increases by 9.8 meters per second for every second that it’s falling. So in our game, we will increase the speed of the player by a certain number for every frame that he is falling.

Continue reading

Sidescrolling Platformer ~Part 3~ The Player

In our last tutorial we programmed the background so that it scrolls when we control it with the arrow keys. But as cool as that is, it isn’t enough. Right now the player is nothing more than a a static object on the side of the stage. What we’re going to do in this tutorial is program the player to interact with the background.

Player Mechanics

What code do we add for the player? That’s a BIG question… the fate of our entire game pretty much depends upon how the player interacts with the environment. In order to stay organized, I’ll outline all the basic concepts the player should follow:

  • Smooth Movement: The player should accelerate smoothly upon pressing the arrow key, and glide to a stop due to friction when the arrow key is released.
  • Collisions: The player should not be able to walk through walls, fall through the ground, or jump through ceilings.
  • Gravity: The player should be pulled downwards unless he is standing on the ground.
  • Jumping: If the player is standing on the ground, he should be able to jump upwards.

Continue reading

Sidescrolling Platformer ~Part 2~ Scrolling the Background with the Arrow Keys

After setting up the basic outline of the platformer in Part 1, we will create a scrolling effect for the background in this tutorial which will be controlled by the arrow keys.

Keyboard Controls

One of the most useful things to be able to do with AS3 is to use the keyboard to control the game. It requires a bit of code, but once you learn to do it you will have a very important building block for any game.

Start out by adding the following code to the Actions panel on frame 1 of the timeline:

Continue reading

Sidescrolling Platformer ~Part 1~ Setup and Planning

Welcome to my new tutorial series: how to make a simple art-based sidescrolling platformer game! You guys requested it, so here it is:

(This tutorial will be a bit more advanced, but still very understandable for a beginner or intermediate programmer. If you are completely new to programming check out my quick Getting Started series, and then try out the Pong tutorials for more experience.)

Why make a sidescroller?

Because they are awesome. In terms of how fun a game is, sidescrolling games are pretty much as good as you can get, at least in the 2D game world. This can be seen in the wild popularity of the original Mario, Metroid, Megaman, or Sonic the Hedgehog titles, as well as modern classics like the Fancy Pants Adventures. If you can master the basic mechanics behind a side scrolling game, you will have a versatile game engine from which you can build tons of awesome games.

Without further ado, let’s get into our game.

Continue reading