Book Image

Flash Game Development by Example

By : Emanuele Feronato
Book Image

Flash Game Development by Example

By: Emanuele Feronato

Overview of this book

<p>You can't call yourself a Flash game developer unless you know how to build certain essential games, and can quickly use the skills and techniques that make them up.<br /><br />Flash Game Development by Example is an ultra-fast paced game development course. Learn step-by-step how to build 10 classic games. Each game introduces new game development skills, techniques, and concepts. By the end of the book you will have built ten complete games &ndash; and have the skills you need to design and build your own game ideas.<br /><br />The book starts with simple well known puzzle games: Concentration and Minesweeper. After learning the basics of game design you&rsquo;ll introduce AI with a four-in-a-row game. Then as you build your own versions of old arcade games such as Snake, Tetris, and Astro Panic. The book ends with a collection of modern casual classics.</p>
Table of Contents (17 chapters)
Flash Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Where to Go Now
Index

Managing remaining lines


When a line is removed, probably there are some tetrominoes above it, just like in the previous picture. Obviously you can't leave the game field as is, but you have to make the above pieces fall down to fill the removed lines.

The idea: Check all pieces above the removed line and move them down to fill the gap left by the removed line.

The development: We can do it by simply moving down one tile, all tetrominoes pieces above the line we just deleted, and updating fieldArray array consequently.

Change checkForLines function this way:

private function checkForLines():void {
  for (var i:int=0; i<20; i++) {
    if (fieldArray[i].indexOf(0)==-1) {
      for (var j:int=0; j<10; j++) {
        fieldArray[i][j]=0;
        removeChild(getChildByName("r"+i+"c"+j));
      }
      
for (j=i; j>=0; j--) {
        for (var k:int=0; k<10; k++) {
          if (fieldArray[j][k]==1) {
            fieldArray[j][k]=0;
            fieldArray[j+1][k]=1;
            getChildByName...