home *** CD-ROM | disk | FTP | other *** search
- function buildMap(map)
- {
- var _loc3_ = this;
- mapWidth = map[0].length;
- mapHeight = map.length;
- var _loc2_ = 0;
- while(_loc2_ < mapHeight)
- {
- var _loc1_ = 0;
- while(_loc1_ < mapWidth)
- {
- _loc3_.attachMovie("tile","t_" + _loc2_ + "_" + _loc1_,++d);
- t = _loc3_["t_" + _loc2_ + "_" + _loc1_];
- t._x = _loc1_ * tileW;
- t._y = _loc2_ * tileH;
- t.gotoAndStop(map[_loc2_][_loc1_]);
- t.shapePos = null;
- t.x = _loc1_;
- t.y = _loc2_;
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- duplicateMovieClip("tempTile","temp",16384 + ++d);
- duplicateMovieClip("tempTar","tar",16384 + ++d);
- temp._x = -100;
- temp._y = -100;
- tar._x = -100;
- tar._y = -100;
- timerID = setInterval(gameTime,tc);
- }
- function addTiles(cn)
- {
- var _loc1_ = cn;
- var _loc2_ = _root;
- while(_loc1_ >= 0)
- {
- cx = int(random(10));
- cy = int(random(10));
- t = _loc2_["t_" + cy + "_" + cx];
- if(t.shapePos == null)
- {
- t.shapePos = int(random(6)) + 1;
- t.gotoAndStop(2);
- t.shape.gotoAndStop(t.shapePos);
- myMap[cy][cx] = 0;
- _loc1_ = _loc1_ - 1;
- }
- }
- }
- function findTile(y, x)
- {
- var _loc1_ = y;
- var _loc2_ = x;
- var _loc3_ = _root;
- s = _loc3_["t_" + _loc1_ + "_" + _loc2_].shapePos;
- if(_loc3_["t_" + (_loc1_ - 1) + "_" + _loc2_].shapePos == s or _loc3_["t_" + (_loc1_ + 1) + "_" + _loc2_].shapePos == s)
- {
- _loc3_["t_" + _loc1_ + "_" + _loc2_].gotoAndPlay(3);
- _loc3_["t_" + _loc1_ + "_" + _loc2_].shapePos = null;
- myMap[_loc1_][_loc2_] = 1;
- sc++;
- if(_loc3_["t_" + (_loc1_ - 1) + "_" + _loc2_].shapePos == s)
- {
- findTile(_loc1_ - 1,_loc2_);
- }
- if(_loc3_["t_" + (_loc1_ + 1) + "_" + _loc2_].shapePos == s)
- {
- findTile(_loc1_ + 1,_loc2_);
- }
- }
- if(_loc3_["t_" + (_loc1_ - 1) + "_" + _loc2_].shapePos == s)
- {
- _loc3_["t_" + (_loc1_ - 1) + "_" + _loc2_].gotoAndPlay(3);
- _loc3_["t_" + (_loc1_ - 1) + "_" + _loc2_].shapePos = null;
- myMap[_loc1_ - 1][_loc2_] = 1;
- sc++;
- }
- if(_loc3_["t_" + (_loc1_ + 1) + "_" + _loc2_].shapePos == s)
- {
- _loc3_["t_" + (_loc1_ + 1) + "_" + _loc2_].gotoAndPlay(3);
- _loc3_["t_" + (_loc1_ + 1) + "_" + _loc2_].shapePos = null;
- myMap[_loc1_ + 1][_loc2_] = 1;
- sc++;
- }
- }
- function addScore()
- {
- if(sc > 0)
- {
- score += sc * 100;
- frame = sc * 35;
- textClip.gotoAndPlay(frame);
- wipe.start(0,1);
- }
- }
- function countTiles()
- {
- var _loc3_ = 0;
- var _loc2_ = 0;
- while(_loc2_ < mapHeight)
- {
- var _loc1_ = 0;
- while(_loc1_ < mapWidth)
- {
- if(_root["t_" + _loc2_ + "_" + _loc1_].shapePos != null)
- {
- _loc3_ = _loc3_ + 1;
- }
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- return _loc3_;
- }
- function gameTime()
- {
- var _loc1_ = _root;
- bar._height = barHeight--;
- if(bar._height <= 0 and _loc1_.playGame == true)
- {
- var _loc2_ = _loc1_.countTiles();
- l++;
- if(_loc2_ < 96)
- {
- barHeight = 50;
- _loc1_.blip.start(0,1);
- _loc1_.addTiles(4);
- if(l == 12)
- {
- l = 0;
- level++;
- clearInterval(timerID);
- if(tc > 30)
- {
- tc--;
- }
- timerID = setInterval(gameTime,tc);
- }
- }
- else
- {
- clearInterval(timerID);
- _loc1_.playGame = false;
- _loc1_.gotoAndStop(3);
- }
- }
- }
- myMap = [[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,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],[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]];
- tileW = 28;
- tileH = 28;
- l = 0;
- tc = 50;
- barHeight = 50;
- hit = null;
- sc = 0;
- score = 0;
- level = 1;
- movX = new Array();
- movY = new Array();
- buildMap(myMap);
- addTiles(7);
- playGame = true;
- stop();
-