Sidescrolling Platformer — Part 11 — Fixing the bullets

Although we did get some functional bullets last time by using the Bullet class, we still need to make some major improvements. First of all, the bullets are added directly to the stage and have no idea about the scrollX and scrollY variables, so they don’t react when the player moves left, right, up, or down. Also, the bullets move at a sluggish pace — if they did react to the player’s movements, you could practically outrun them. Finally, they are never actually removed from the stage, so we waste precious memory that slows down the game. Imagine that we fired 1,000,000 bullets. The game would still be keeping track of all of them, constantly updating their positions, even if they are no longer on the stage. There’s some more code we can add to the bullets to handle all of this, and we are going to implement it in this tutorial.

Continue reading


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