{"id":1073,"date":"2009-01-10T08:05:47","date_gmt":"2009-01-10T12:05:47","guid":{"rendered":"http:\/\/www.mrsunstudios.com\/?p=1073"},"modified":"2022-05-29T08:23:31","modified_gmt":"2022-05-29T12:23:31","slug":"tutorial-create-a-brick-breaker-game-in-as2-part-6","status":"publish","type":"post","link":"http:\/\/www.mrsunstudios.com\/blog\/flash\/tutorial-create-a-brick-breaker-game-in-as2-part-6\/","title":{"rendered":"Tutorial: Create a Brick Breaker Game in AS2 &#8211; Part 6"},"content":{"rendered":"<div class=\"toc\">\n<h3>Table of Contents<\/h3>\n<ol>\n<li><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2\">Coding Paddle Movement<\/a><\/li>\n<li><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2-part-2\">Programming the Ball<\/a><\/li>\n<li><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2-part-3\">Setting Up the Bricks on Stage<\/a><\/li>\n<li><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2-part-4\">Hit Testing the Bricks<\/a><\/li>\n<li><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2-part-5\">Creating Levels<\/a><\/li>\n<li class=\"c_chap\"><a href=\"http:\/\/www.mrsunstudios.com\/2009\/01\/tutorial-create-a-brick-breaker-game-in-as2-part-6\">Finishing Touches<\/a><\/li>\n<\/ol>\n<\/div>\n<h3>Step 6: Finishing Touches<\/h3>\n<p>Well, we&#8217;re almost done with our game, now we just have to add some finishing touches. I won&#8217;t make a menu system like you usually should in a game before releasing it. But, this is just a tutorial, and hopefully you&#8217;ve learned something. You probably already know how to make a menu anyway. Also, I&#8217;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&#8217;t , there&#8217;s always the source file at the bottom.<\/p>\n<p>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&#8217;s an example of a 5 level game (Put it on the first frame).<\/p>\n<pre lang=\"actionscript\">\r\n\/\/The array code for lvl 1\r\n\/\/All of the later levels add one more row of bricks\r\nvar lvl1Code:Array = new Array(1,1,1,1,1,1,1);\r\nvar lvl2Code:Array = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1);\r\nvar 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);\r\nvar 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);\r\nvar 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);\r\n\/\/The array that contains all of the level codes\r\nvar lvlArray:Array = new Array(lvl1Code, lvl2Code, lvl3Code, lvl4Code, lvl5Code);\r\n<\/pre>\n<p>It&#8217;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 <tt>txtStart<\/tt>, and make sure it isn&#8217;t selectable.<br \/>\n<img src=\"http:\/\/mrsunstudios.com\/obj\/tuts\/brick-breaker-as3\/pt6\/text-properties.gif\" alt=\"Make sure that these properties are what you have\" \/><\/p>\n<p>Next, add this code at the end of the frame.<\/p>\n<pre lang=\"actionscript\">\r\n\/\/setting the text's word\r\ntxtStart.text = \"Click To Begin\";\r\n<\/pre>\n<p>You can make the text different, but don&#8217;t be too mean. Next, we have to remove the text, which we can do in the mcBg&#8217;s <tt>onRelease()<\/tt> function. We aren&#8217;t going to remove the text field itself because we need it again for every level.<\/p>\n<pre lang=\"actionscript\">\r\n\/\/removing the \"Click to Start\" Text\r\ntxtStart.text = '';\r\n<\/pre>\n<p>Now, we have to reset it every level. I&#8217;m not going to tell you how to do it. I hope you&#8217;ve learned enough to be able to.<\/p>\n<p>Now, we can make the scoring happen. 10 points should be awarded to the player for destroying one brick. I&#8217;ll leave it to you to find out how to do this.<\/p>\n<p>The next thing we have to do is display the current level, the score, and how many lives the user has. This will be pretty simple as well, so I won&#8217;t really go into details about how to do it. Just create a dynamic text field and update it in the <tt>onEnterFrame()<\/tt> function. Pretty easy, eh?<\/p>\n<h4>The Final Product<\/h4>\n<p><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"550\" height=\"400\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"src\" value=\"http:\/\/www.mrsunstudios.com\/obj\/tuts\/brick-breaker-as2\/pt6\/source.swf\" \/><embed type=\"application\/x-shockwave-flash\" width=\"550\" height=\"400\" src=\"http:\/\/www.mrsunstudios.com\/obj\/tuts\/brick-breaker-as2\/pt6\/source.swf\"><\/embed><\/object><\/p>\n<p><a href=\"http:\/\/mrsunstudios.com\/obj\/tuts\/brick-breaker-as2\/pt6\/source.fla\">Source .fla File<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents Coding Paddle Movement Programming the Ball Setting Up the Bricks on Stage Hit Testing the Bricks Creating Levels Finishing Touches Step 6: Finishing Touches Well, we&#8217;re almost done with our game, now we just have to add some finishing touches. I won&#8217;t make a menu system like you usually should in a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,7,65,4,6],"tags":[25,7,14,66,26,67,19,18,22],"_links":{"self":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1073"}],"collection":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/comments?post=1073"}],"version-history":[{"count":6,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1073\/revisions"}],"predecessor-version":[{"id":1505,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1073\/revisions\/1505"}],"wp:attachment":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/media?parent=1073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/categories?post=1073"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/tags?post=1073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}