Welcome to Part 2 of the Actionscript 3 Flash game tutorial series for Pong!
Make sure you check out Part 1 if you haven’t done that already. And if you are completely new to programming, my Getting Started tutorials are the place for you.
Enough talk, let’s code.
Step Two: Program the basic game loop and the ball
First things first, we need to name each instance of our game pieces — this is what we’ll use to refer to each object in the code. Name the paddle on the left “playerPaddle” (no quotes), the paddle on the right “cpuPaddle”, and the ball can just be named “ball”.
In 1972 Atari pioneered the video game industry with the release of Pong. If you think of classic games, Pong is almost always near the top of the list. So it is fitting that Pong should be at least one of your first flash games you make. In this tutorial, we are going to create a complete Pong game from start to finish.
This is intended for beginners, but if you have never programmed at all before you should check out my Getting Started tutorial first.
This is what we are going to create over the next 6 tutorials:
This is part 2 of 2 of the Getting Started with AS3 series. Click here to view part 1.
OK, so we’ve covered variables, event listeners, and functions. Now let’s check out the code that actually does stuff.
The final part of code we are going to look at right now is what I call the “action” code — the code that actually does things. Now, in a game, what we could do with action code includes basically anything you can think of: you can move and animate objects, perform calculations, manipulate variables, call functions, and “trace” out data to your output window, just to name a few.
So you want to make flash games, but you’ve never written a line of code before?
Don’t worry, this is just the place to learn how. Instead of getting caught up with complicated terms, and code that doesn’t do anything cool, we’ll jump right into the basics and then get started with some real, working game examples. Other websites might go into more depth on fancy code, but the point of this site is games. And the best way to learn games is to learn from experience. Continue reading →