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

Drawing the game field with alternate rows


In odd rows, there can be only seven circles, shifted by R pixels on the right.

The idea: Check whether we are drawing an odd or an even row. Then if we are drawing an even row, draw circles in the same way you just drew, if we are drawing an odd row, shift circles' center by R pixels on the right and don't draw the last circle.

The development: Change placeContainer function this way:

private function placeContainer():void {
  bubCont=new Sprite();
  addChild(bubCont);
  bubCont.graphics.lineStyle(1,0xffffff,0.2);
  for (var i:uint=0; i<11; i++) {
    for (var j:uint=0; j<8; j++) {
      if (i%2==0) {
        bubCont.graphics.drawCircle(R+j*R*2,R+i*R*2,R);
      } else {
        if (j<7) {
          with (bubCont.graphics) {
            drawCircle(2*R+j*R*2,R+i*R*2,R);
          }
        }
      }
    }
  }
}

As we enter the couple of for loops, we check if i is an even number using the modulo operator. In this case, we are drawing circles...