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

Advertisements

Pong ~Part 6~ Scoring Points

Welcome back to the AS3 Game Tuts pong tutorial series. So far in this series we’ve created a working pong game complete with a ball and two paddles. In this tutorial we are going to add a scoring system to the game.

Continue reading

Pong ~Part 5~ Collisions!

This is it. The tutorial you’ve all been waiting for. The tutorial that will bring everything together. The tutorial which will make you cry out in joy– OK, maybe not, I’m getting a little too excited… but seriously this is a good one.

If you haven’t read the whole series yet, I recommend starting at the beginning.

Part 1: Setting up the Project

Part 2: Programming the Ball

Part 3: The Player’s Paddle

Part 4: The CPU’s Paddle

Let’s get started.

So far, we’ve got the ball to move and bounce off walls. We’ve made the playerPaddle be controllable by the mouse. And we’ve told the cpuPaddle to move up or down depending upon the position of the ball. It’s time to turn this into a “real” game by letting the ball be blocked by the paddles.

Hit Testing

The way Flash handles collisions between two objects on the stage is called hit testing. The way it works is that Flash keeps track of invisible bounding boxes around every object on the screen. These bounding boxes are the smallest possible rectangle that your object can fit inside. So for our paddles, the bounding box is exactly the same shape. But for the ball, instead of using the circular 30px by 30px shape we drew, Flash uses a 30px by 30px square.

Continue reading

Resources: Beginner Tutorials

If you’re looking for some great beginner tutorials besides AS3GameTuts’s Getting Started with AS3, or Pong, here is a list of some of my favorites:

Highly Recommended:

The Avoider Game Tutorial – Michael James Williams

This is basically the pinnacle of the flash gaming tutorials for beginners. Michael J Williams takes you through 12 easy-to-follow steps to make an Avoider game complete with many features. After you complete this you will feel very confident with the basics of AS3.

Other Great Tutorials:

How to Create a Brick Breaker Game in AS3 – Flash Game Tuts

This tutorial is from the website that gave me the inspiration for AS3 Game Tuts.  It is a very thorough tutorial on creating a Breakout style game in AS3. This site has many other helpful tutorials for all sorts of game styles.

AS3 101 – ActiveTuts+

So you want to figure out actionscript 3? This is the place to do it. It doesn’t teach you to make any specific games, but if you start from the beginning and read all the way to the end, you will be an actionscript pro.

Flash ball game creation tutorial – Emanuele Feronato

This is a quick tutorial that shows how to move a ball around using the arrow keys. Useful.

Number guessing game in AS3 – iLike2Flash

Create a simple higher-or-lower guessing game in Flash AS3

Kongregate AS3 Shootorials:

This 8 part tutorial series from the Kongregate will teach you to create a horizontal space shooter flash game in AS3. You can see what the result looks like by clicking here.

The AS3 tutorials don’t link to one-another, so bookmark this page if you need to and use this list of links to find each section.

Kongregate AS3 Shootorials – Part 1

Kongregate AS3 Shootorials – Part 2

Kongregate AS3 Shootorials – Part 3

Kongregate AS3 Shootorials – Part 4

Kongregate AS3 Shootorials – Part 5

Kongregate AS3 Shootorials – Part 6

Kongregate AS3 Shootorials – Part 7

Kongregate AS3 Shootorials – Part 8

If you know of any great beginner tutorials that I left out, please let me know in the comments so I can update the list.

And if you think you’re beyond the very basics, you might want to give my Platformer tutorials a try.

Thanks!

Pong ~Part 4~ The CPU’s Paddle

Welcome to part 4 of the Pong tutorial series. Please make sure you have read Part 1Part 2, and Part 3.

Step Four: Program the Computer-controlled Paddle

OK, so the last tutorial was pretty short and sweet. So lets waste no time getting into the next step. This step is pretty important because we begin to look at a very important step in game programming: AI (which stands for Artificial Intelligence).

Artificial Intelligence

Any time when the computer itself needs to control something (like an enemy in a game) and perform certain actions depending on certain conditions, we call this AI. Now, our AI is fairly basic. We need the computer’s paddle to move up and down to try to block the ball from getting past. It would be easy to make the cpuPaddle ALWAYS block the ball — all we would do is constantly set the cpuPaddle.y to the ball.y position. But how do we give the computer the intelligence to act like a normal player, sometimes succeeding and other times failing?

Continue reading

Pong ~Part 3~ The Player’s Paddle

(This is part 3 of the Pong tutorial series. Please read Part 1 and Part 2 if you haven’t done so already.)

Step Three: Program the Player-controlled Paddle

We got the ball to move and bounce off of the walls in our last tutorial. Now it’s time to program the player-controlled paddle. What does the playerPaddle need to do?

  • Set it’s y-position to the y-position of the mouse
  • Stay within the boundaries of the screen
  • Block the ball from passing through it

This will be a pretty simple tutorial section.

Continue reading

10 Tips I Wish I Knew When I Started Programming

When you first start learning to program, there are a bunch of easy mistakes that make you waste time or lose motivation. Here is a list of my Top Ten Tips for new game programmers, which might save you a lot of time and trouble:

1. Start small

  • One of the all-time biggest mistakes for new programmers is to choose a massive project to be their first game (like a complete RPG)
  • I know it’s sometimes hard to hold yourself back, but a lot of people (myself included) have wasted time by trying to take on too big of a project in the beginning
  • Start with small, simple games, and work your way up to the big league once you know what you are doing

Continue reading