Tutorial: Create a Brick Breaker Game in AS3 – Part 6


Written By MrSun at 11:00 am - Friday, August 01st, 2008
Categories: Beginner Tutorials, Flash

Step 6: Finishing Touches

Well, we’re almost done with our game, now we just have to add some finishing touches. I won’t make a menu system like you usually should in a game before releasing it. But, this is just a tutorial, and hopefully you’ve learned something. You probably already know how to make a menu anyway. Also, I’m not going to teach you how to do some of the things that we need because hopefully you can do it yourself. If you can’t , there’s always the source file at the bottom.

Now, where were we? Oh yes. I realized that the last lesson, we were supposed to make more levels. I taught a lot of stuff, but I forgot to make more levels for you! I apologize. Anyway, here’s an example of a 5 level game (Put it on the first frame).

//The array code for lvl 1
//All of the later levels add one more row of bricks
var lvl1Code:Array = new Array(1,1,1,1,1,1,1);
var lvl2Code:Array = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1);
var lvl3Code:Array = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
var lvl4Code:Array = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
var lvl5Code:Array = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
//The array that contains all of the level codes
var lvlArray:Array = new Array(lvl1Code, lvl2Code, lvl3Code, lvl4Code, lvl5Code);

It’ll be a pretty straightforward game. Next, I think the gamer needs to know that he has to click the screen to start, and not think the the game is frozen or something. So, just add a dynamic textfield to the middle of the stage. Give it an instance game of txtStart, and make sure it isn’t selectable.
Make sure that these properties are what you have

Next, add this code at the end of the frame.

//setting the text's word
txtStart.text = "Click To Begin";

You can make the text different, but don’t be too mean. Next, we have to remove the text, which we can do in the beginCode() function. We aren’t going to remove the textfield itself because we need it again for every level.

//removing the "Click to Start" Text
txtStart.text = '';

Now, we have to reset it every level. I’m not going to tell you how to do it. I hope you’ve learned enough to be able to.

The next thing we have to do is display the current level, and how many lives the user has. This will be pretty simple as well, so I won’t really go into details about how to do it. But, I will give you some code to use below all the other.

//creating a function to update the text fields
addEventListener(Event.ENTER_FRAME, updateTextFields);

You can create your own text fields with and update them with that function. But, be sure to remove that listener if the gamer loses, or something bad will happen, something very bad…

And don’t think I forgot about scoring. Just define a variable at the top called score and have it update along with the other stats. Also, you have to make it increase in the Brick class every time the brick is hit. You might want to show the score when the player loses too. But, that’s just optional.

Well, those are all the finishing touches that I’m going to add on to my game at least. Here is the final product of all our work.

The Final Product:

Source Files (Zipped)

Read More...

50 Ways to Make Us LOVE Your Flash Game


Written By MrSun at 8:34 am - Friday, August 01st, 2008
Categories: Flash

Make it funny Give it an intriguing title Make an interesting storyline Let us customize our experience If it’s hard or confusing, make a walkthrough for us If it’s complicated, write some good documentation Keep track of all our statistics so we can see how well we’re doing Add Easter Eggs (If you do, tell […]

Read More...

Tutorial: Create a Brick Breaker Game in AS3 – Part 5


Written By MrSun at 12:44 pm - Thursday, July 31st, 2008
Categories: Beginner Tutorials, Flash

Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 5: Creating Levels Now that we’ve got the basic gameplay down, we can create some levels. Because we’re making only a simple game, we aren’t going to make that many. But […]

Read More...

Tutorial: Create a Brick Breaker Game in AS3 – Part 4


Written By MrSun at 10:33 am - Thursday, July 31st, 2008
Categories: Beginner Tutorials, Flash

Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 4: Hit Testing the Bricks Now that we’ve actually made the bricks, we can now break them with our ball… Anyway, this will be pretty easy to accomplish. But, if you […]

Read More...

Tutorial: Create a Brick Breaker Game in AS3 – Part 3


Written By MrSun at 1:25 pm - Wednesday, July 30th, 2008
Categories: Beginner Tutorials, Flash

Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 3: Setting Up the Bricks on Stage Ok, we’ve got the paddle and the ball. Now, the only major thing left to program is the brick. This is also the hardest […]

Read More...

Tutorial: Create a Brick Breaker Game in AS3 – Part 2


Written By MrSun at 9:47 am - Wednesday, July 30th, 2008
Categories: Beginner Tutorials, Flash

Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 2: Programming the Ball The next obvious step in creating a brick breaker game is making the ball. So, I’m just going to make a small 10×10 pixel white circle into […]

Read More...

Tutorial: Create a Brick Breaker Game in AS3


Written By MrSun at 9:44 am - Tuesday, July 29th, 2008
Categories: Beginner Tutorials, Flash

Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 1: Coding Paddle Movement Ok, this is going to be my first tutorial on hopefully a simple subject. This is probably going to be broken up into a few parts. So, […]

Read More...

Game Development Spotlight: Xylophone Master


Written By MrSun at 9:00 am - Monday, July 28th, 2008
Categories: Flash

As you may not have known, my latest flash game, Xylophone Master, has recently been released. It was my first attempt at a real feature-filled flash game, and it was quite a bittersweet success. Let me first tell you about the actual game itself. It is a rhythm-based game where all 8 of he home […]

Read More...

The Spotlight


Written By MrSun at 6:46 pm - Sunday, July 27th, 2008
Categories: Uncategorized

I’ve just added a little section to the site called “The Spotlight”. You can see it up on the navigation bar. I took the concept of the Game Development Spotlight and expanded it a bit into something more. In order to motivate myself to make better flash games and have a great time while doing […]

Read More...

Link Post Sunday 07/27


Written By MrSun at 10:08 am - Sunday, July 27th, 2008
Categories: Uncategorized

Emanuele Feronato made a couple of posts about making a flash arcade site in WordPress. He gives some useful information on it and just released a 2nd part today. Are you Getting Pumped for Flash CS4? Will at Ahrooga made a nice post for beginners called Tips for Learning ActionScript 3.0 Gabriel Bianconi made a […]

Read More...