Sidescrolling Platformer — Part 10 — Shooting

Welcome back to the flash game tutorial: how to make a side scrolling platformer game in actionscript 3. I can’t believe we’re already up to part ten! As you can probably tell from the title, this tutorial part will exclusively feature shooting. Not all platformer games require this feature, but I’ve had a bunch of requests for this tutorial — probably because side scrolling shooters are an amazing game genre (for example, the classic Metroid games). We don’t have anything yet for our bullets to interact with, but don’t worry — next tutorial we will add the enemies. For now, let’s just focus on getting our hero to shoot.

Here is a preliminary demo of what we’ll be creating. Use the space bar to fire.

An External Actionscript File

…I knew this moment would arrive eventually… the moment when — *gasp* — we finally need to use a custom class and an external actionscript file. If you’ve never programmed anything with Object Oriented Programming before, and you’ve never created an external .as file, this might seem intimidating. Or perhaps you have no idea what I’m talking about. No matter where you stand right now, I hope that by the end of this tutorial you will have a solid idea of what external classes are, why we use them, and how to create a Class for the bullets. In future tutorials we will go into more depth on the topic.

Continue reading

Sidescrolling Platformer — Part 9 — Animated Player Movements

All great platformers have animated heroes. Even Super Mario, which was released in 1985, used several animations for the player. Why? Because it would look completely unrealistic if Mario just stood frozen in one animation while he runs and jumps around the level. So it makes sense that we should add animations to our player. This will add yet another step of realism to the game.

Try running, jumping, or standing still. See how the player’s animation state reacts:

My art could definitely be improved, but I’ll demonstrate how to create these 3 animations for simplicity’s sake.

The Structure

The most important aspect of giving any game element multiple animation states, is to make sure you structure it correctly. When I first started programming, I tried to put all of the animations on a single timeline, and the resulting structure was too cluttered and complicated that it was difficult to make things work the way I wanted them to. So now I’m sharing with you a simpler method.

Continue reading

Sidescrolling Platformer — Part 8 — Multiple Levels

Here’s the post you’ve all been waiting for… how to connect multiple levels in your platformer!

Try out this demo. Press the down arrow key upon opening the door to warp to the next level:

After adding the door and key last time, the next step is to make the door lead to the next level. “How?”, you might ask… just read on to see the magic unfold.

Continue reading

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

Saving and Loading in Actionscript 3 (Mini-Lesson)

One thing you want to do as a game developer is make your players want to come back to your game more than once. And one of the best ways to accomplish this is to enable them to save their data for persistent gameplay. You might expect saving and loading to be tough to implement, but actionscript 3 is helpful enough to include the powerful SharedObject, which makes saving and loading data a piece of cake.

In this tutorial, we will create the following demo. Click the “+1” button a few times to add to your score. If you refresh this webpage without clicking the “save” button, your score will revert to 0 when the page loads. But if you do click the “save” button, your score will load automatically the next time you load the page. Try it out!

Continue reading to learn how to save and load data in actionscript 3

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

AS3 Health Bar Tutorial (Mini-Lesson)

I’ve received a request to teach how to make a health bar in actionscript 3. Health bars can be found in all sorts of games, so I decided not to confine it to a single tutorial series. Instead, I’ve made this the first of a new section of Mini-Lessons on this site, to cover miscellaneous small game mechanics which can be used in a variety of games.

This tutorial is heavily image-based :-)

Here’s the demo of what we are going to create in this tutorial.

Easy to make. Easy to customize.

Pretty cool, huh?

Continue reading

News! Birthday, domain name, stats, and more!

This is the final month of this site’s first year. That’s right, next month, on March 5, AS3GameTuts is turning 1! (Feel free to wish us a happy birthday!)

Thanks to all of your amazing support over the past year. With little advertising at all, this site has been viewed over ten thousand times since its creation, mostly during the past few months.

Check out the graph of the site views over the past year,with February only 6 days under way.

If you’ve visited this site before, you would have seen the URL listed as as3gametuts.wordpress.com.

But check it out — we now have a brand new domain name: AS3GameTuts.com

You can think of this as marking the graduation out of the “beta” version of the site :-)

The first year has been great, with 3 tutorial series and a couple of extra posts thrown in for fun. But the next year will be much, much greater for AS3 Game Tuts. Stay tuned for even more tutorials, including the conclusion to the platformer, a turn-based RPG, an overhead shooter, an overhead adventure (think classic Legend of Zelda), as well as a plethora of mini lessons, extra tips, and maybe even some guest posts. Stay tuned. (I’ll try to keep to this promise… if I’m falling behind, feel free to give me a gentle reminder.)

The goal of this site is to help you all learn to make the games you’ve dreamed of creating. Hopefully my choice of tutorials which I plan to write accomplishes this, but if there is anything you would like to know, I am completely open to suggestions and requests.

So please, if there is anything you wish for me to write about, or even if you just have a general comment or suggestion about the site, fill out the following form. Thanks!

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