Home Projects Flash CS3 How to Create a Tile Game Like Destruct-O-Match on Neopets.com





Forgot your password?
Forgot your username?
No Account Yet? Create an account

Like it? Share it!

Add to: JBookmarks Add to: Facebook Add to: Windows Live Add to: Ximmy Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: Jumptags Add to: Upchuckr Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Yahoo Add to: Blogmarks Add to: Diigo Add to: Technorati Information

How to Create a Tile Game Like Destruct-O-Match on Neopets.com PDF Print E-mail
User Rating: / 2
PoorBest 
Projects - Flash CS3
Written by drooza   
Tuesday, 23 September 2008 19:02
Article Index
How to Create a Tile Game Like Destruct-O-Match on Neopets.com
Linking the Tile class
Creating the Tile Game Engine
Initializing Level Functions
In Game Functions
Clumping Functions
End Of Level / Game Functions
Creating the .fla
Let's Play the Game!
All Pages

If you aren't already familiar with Neopets.com then you should go check them out. I believe they have one of - if not - the biggest audiences of users of online games.  With just over 660 billion page views they have a massive audience.  Neopets is an online community based on an online pet and in order to feed this pet you must play online games (to gain money or neopoints) to buy food.  This mini-world even has their own economy and stock market!

Neopets.comOne of the games there caught my eye, Destruct-o-Match, which is in its third installment.  One of my favorite time-killing games.  I didn't just kill time playing the game but analyzing how it works and developing my own version. 

Now I'm going to show you how I did it using Flash CS3 and Actionscript 3.0.

First we'll start off with the idea of the game:  A group of colored tiles that when 2 or more are grouped together may be destroyed in exchange for points.  If you destroy all the blocks on the field, or you gain enough points, you advance to the next level

 

Second we'll start building the foundation of the game.  What other great place to start than the tiles!  Lets start off with a new class named Tile.

 /** Linkage class for the Library Item Tile. The library item must have 1 tile per
* frame with a flag: "blank" on the last frame to denote it's empty. This will
* enable easy customization and updating.
*
* @author dRooza
*/

package
{
import flash.display.MovieClip;
import fl.transitions.Tween;


public class Tile extends MovieClip
{
public var checked:Boolean; //flag to eliminate duplicate checking
public var highLighted:Boolean; //flag for destruction destroy
public var column:int; //coordinates for where
public var row:int; // tile is located

// pointer to tween so garbage collector doesn't remove prior to completion
public var tween:Tween;


/** Constructor initializes tile to a random frame and sets the boolean
* highlighted to false.
*/
public function Tile()
{
turnOff();
this.gotoAndStop(Math.round(Math.random() * (this.totalFrames - 1)));
}

/** Highlights the tile, marking it as checked.
*
*/
public function turnOn():void
{
this.alpha = .25;
this.highLighted = true;
markAsChecked();
}

/** Sets tile back to normal state: not checked nor highlighted
*
*/
public function turnOff():void
{
this.alpha = 1;
this.highLighted = false;
this.checked = false;
}

/** Checks to see if the tile is highlighted
* @return if the tile is highlighted
*/
public function isHighLighted():Boolean
{
return highLighted;
}

/** Set the tile as checked to prevent it from being checked again
*
*/
public function markAsChecked():void
{
checked = true;
}

/** Checks to see if the tile is highlighted
* @return if the tile has been checked
*/
public function isChecked():Boolean
{
return checked;
}

/** Removes the tile from the stage
*
*/
public function destroy()
{
if(this.parent != null)
{
this.parent.removeChild(this);
}
}
} //end class
} //end package

 



Comments
Add New Search
Bug Found
drooza (SAdministrator) 2008-09-23 19:59:00

There's this one bug that happens sparingly. Sometimes the tiles don't
fall into correct place and are stuck, suspended in the air. If I remove the
animation totally, then no more bug. I've got that much.

I'm thinking I have
to check where the tile is located when the animation stops.
Bug Fix:
drooza (SAdministrator) 2008-11-07 09:54:10

Because a tween object is instantiated inside an if statement (oops) the
garbage collector is taking care of business and removing the
tween before it completes.

By making this tween a part of the Tile
class, this may fix the problem.

Other fixes in the comments section
of this page: http://livedocs.adobe.com/flash/9.0/ActionScrip...
Losing?
KeenEyes (76.174.154.xxx) 2008-10-09 18:52:29

How do you lose in this game again? lol
drooza (SAdministrator) 2008-10-09 19:11:10

If you don't achieve the points set by the game for that level, you lose.
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
:angry::0:confused::cheer:B)
:evil::silly::dry::lol::kiss:
:D:pinch::(:shock::X
:side::):P:unsure::woohoo:
:huh::whistle:;):s:!:
:?::idea::arrow:
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Saturday, 22 November 2008 13:05 )
 

Make a Donation!

Advertisement
Banner

HomeProjectsSnippetsContact Me

Copyright © 2008, Drooza.com