home *** CD-ROM | disk | FTP | other *** search
- function buildMap(map, exit)
- {
- var _loc3_ = map;
- getwh(level);
- mapWidth = _loc3_[0].length;
- mapHeight = _loc3_.length;
- var _loc2_ = 0;
- while(_loc2_ < mapHeight)
- {
- var _loc1_ = 0;
- while(_loc1_ < mapWidth)
- {
- this.attachMovie("tile","t_" + _loc2_ + "_" + _loc1_,++d);
- t = this["t_" + _loc2_ + "_" + _loc1_];
- t._height = tileH;
- t._width = tileW;
- t._x = _loc1_ * tileW;
- t._y = _loc2_ * tileH;
- t.w_0._visible = Number(_loc3_[_loc2_][_loc1_].substr(0,1));
- t.w_1._visible = Number(_loc3_[_loc2_][_loc1_].substr(1,1));
- t.w_2._visible = Number(_loc3_[_loc2_][_loc1_].substr(2,1));
- t.w_3._visible = Number(_loc3_[_loc2_][_loc1_].substr(3,1));
- t.exit._visible = false;
- _loc1_ = _loc1_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- var c = 0;
- while(c < exit.length)
- {
- var x = exit[c][0];
- var y = exit[c][1];
- this["t_" + y + "_" + x].exit._visible = true;
- c++;
- }
- }
- function createBall(x, y)
- {
- var _loc1_ = this;
- _loc1_.attachMovie("ball","ball" + w,++w);
- var bounds = _loc1_["b" + w].getBounds(_loc1_);
- var tilex = tileW * x + bounds.xMax;
- var tiley = tileH * y + bounds.yMax;
- b = _loc1_["ball" + w];
- b._height = tileH;
- b._width = tileW;
- b._x = tilex;
- b._y = tiley;
- b.onEnterFrame = function()
- {
- var _loc1_ = this;
- if(moveRight)
- {
- _loc1_._x += step;
- counter++;
- if(counter == 4)
- {
- moveRight = false;
- playGame = true;
- }
- }
- if(moveLeft)
- {
- _loc1_._x -= step;
- counter++;
- if(counter == 4)
- {
- moveLeft = false;
- playGame = true;
- }
- }
- if(moveDown)
- {
- _loc1_._y += step;
- counter++;
- if(counter == 4)
- {
- moveDown = false;
- playGame = true;
- }
- }
- if(moveUp)
- {
- _loc1_._y -= step;
- counter++;
- if(counter == 4)
- {
- moveUp = false;
- playGame = true;
- }
- }
- if(playGame)
- {
- var dy = Math.floor((_loc1_._y + tileH) / tileH);
- var uy = Math.floor((_loc1_._y - tileH) / tileH);
- var lx = Math.floor((_loc1_._x - tileW) / tileW);
- var rx = Math.floor((_loc1_._x + tileW) / tileW);
- var _loc3_ = Math.floor(_loc1_._x / tileW);
- var _loc2_ = Math.floor(_loc1_._y / tileH);
- if(_loc1_.direction == "right")
- {
- if(_root["t_" + _loc2_ + "_" + _loc3_].w_1._visible == false)
- {
- if(_root["t_" + _loc2_ + "_" + rx].w_3._visible == false)
- {
- playGame = false;
- moveRight = true;
- counter = 0;
- }
- }
- }
- if(_loc1_.direction == "left")
- {
- if(_root["t_" + _loc2_ + "_" + _loc3_].w_3._visible == false)
- {
- if(_root["t_" + _loc2_ + "_" + lx].w_1._visible == false)
- {
- playGame = false;
- moveLeft = true;
- counter = 0;
- }
- }
- }
- if(_loc1_.direction == "down")
- {
- if(_root["t_" + _loc2_ + "_" + _loc3_].w_2._visible == false)
- {
- if(_root["t_" + dy + "_" + _loc3_].w_0._visible == false)
- {
- playGame = false;
- moveDown = true;
- counter = 0;
- }
- }
- }
- if(_loc1_.direction == "up")
- {
- if(_root["t_" + _loc2_ + "_" + _loc3_].w_0._visible == false)
- {
- if(_root["t_" + uy + "_" + _loc3_].w_2._visible == false)
- {
- playGame = false;
- moveUp = true;
- counter = 0;
- }
- }
- }
- if(_root["t_" + _loc2_ + "_" + _loc3_].exit._visible == true)
- {
- _root["t_" + _loc2_ + "_" + _loc3_].exit._visible = false;
- _root["t_" + _loc2_ + "_" + _loc3_].exit.gotoAndStop(2);
- wipe.start(0,1);
- ex++;
- if(ex == exitCounter)
- {
- nextFrame();
- }
- }
- if(moveRight == false and moveUp == false and moveDown == false and moveLeft == false)
- {
- if(Key.isDown(39))
- {
- _loc1_.direction = "right";
- }
- if(Key.isDown(37))
- {
- _loc1_.direction = "left";
- }
- if(Key.isDown(40))
- {
- _loc1_.direction = "down";
- }
- if(Key.isDown(38))
- {
- _loc1_.direction = "up";
- }
- if(Key.isDown(17))
- {
- level--;
- nextFrame();
- }
- }
- }
- };
- }
- function doLevel(lv)
- {
- switch(lv)
- {
- case 1:
- createBall(1,1);
- step = 10;
- exitCounter = 1;
- break;
- case 2:
- createBall(3,3);
- step = 9;
- exitCounter = 1;
- break;
- case 3:
- createBall(1,4);
- step = 9;
- exitCounter = 1;
- break;
- case 4:
- createBall(1,3);
- step = 8;
- exitCounter = 1;
- break;
- case 5:
- createBall(5,2);
- step = 8;
- exitCounter = 1;
- break;
- case 6:
- createBall(6,4);
- step = 7;
- exitCounter = 1;
- break;
- case 7:
- createBall(3,4);
- step = 10;
- exitCounter = 5;
- break;
- case 8:
- createBall(3,3);
- step = 10;
- exitCounter = 8;
- break;
- case 9:
- createBall(3,3);
- step = 10;
- exitCounter = 8;
- break;
- case 10:
- createBall(1,3);
- step = 9;
- exitCounter = 6;
- break;
- case 11:
- createBall(5,5);
- step = 7;
- exitCounter = 15;
- }
- }
- function getwh(lv)
- {
- switch(lv)
- {
- case 1:
- tileW = 40;
- tileH = 40;
- break;
- case 2:
- tileW = 36;
- tileH = 36;
- break;
- case 3:
- tileW = 36;
- tileH = 36;
- break;
- case 4:
- tileW = 32;
- tileH = 32;
- break;
- case 5:
- tileW = 32;
- tileH = 32;
- break;
- case 6:
- tileW = 28;
- tileH = 28;
- break;
- case 7:
- tileW = 40;
- tileH = 40;
- break;
- case 8:
- tileW = 40;
- tileH = 40;
- break;
- case 9:
- tileW = 40;
- tileH = 40;
- break;
- case 10:
- tileW = 36;
- tileH = 36;
- break;
- case 11:
- tileW = 28;
- tileH = 28;
- }
- }
- myMap1 = [["0000","0000","0000","0000","0000","0000"],["0000","1001","1010","1000","1001","1100"],["0000","0001","0000","0000","0000","0110"],["0000","0101","0000","0010","0000","0100"],["0000","0001","0010","0000","0000","0110"],["0000","0011","0010","0010","0011","0110"]];
- myMap2 = [["0000","0000","0000","0000","0000","0000","0000"],["0000","1101","1000","1010","1000","1100","1100"],["0000","0001","0000","0000","0000","0010","0100"],["0000","0101","0000","0111","0000","0000","0110"],["0000","0011","0000","0000","1101","0000","0100"],["0000","0001","0000","0000","0000","0000","0110"],["0000","0011","0010","0111","0010","0010","0110"]];
- myMap3 = [["0000","0000","0000","0000","0000","0000","0000"],["0000","1001","1000","1110","1000","1000","1110"],["0000","0011","0000","0010","0000","0000","0100"],["0000","0001","0000","0000","0000","0000","0111"],["0000","0001","0000","0000","0011","0000","0100"],["0000","0111","0000","0000","0000","0000","0100"],["0000","0011","0110","0010","0010","0111","0110"]];
- myMap4 = [["0000","0000","0000","0000","0000","0000","0000","0000"],["0000","1001","1000","1000","1010","1100","1000","1100"],["0000","0011","0100","0000","0000","0010","0000","0110"],["0000","0011","0000","0100","0000","0000","0000","0100"],["0000","0001","0000","0000","0000","0110","0000","0110"],["0000","0001","0000","0100","0000","0000","0000","0110"],["0000","0011","1100","0000","0000","0000","0010","0100"],["0000","0011","0010","0110","0010","0010","0011","0110"]];
- myMap5 = [["0000","0000","0000","0000","0000","0000","0000","0000","0000"],["0000","1101","1000","1010","1100","1000","1000","1110"],["0000","0001","0000","0000","0000","0000","0000","0100"],["0000","0001","0010","0100","0000","0000","0100","0100"],["0000","0001","0000","0000","0110","0100","0000","0110"],["0000","0011","0000","0000","0000","0010","0000","0100"],["0000","0001","0000","0111","0000","0000","0000","0100"],["0000","0011","0010","0010","0110","0010","0010","0111"]];
- myMap6 = [["0000","0000","0000","0000","0000","0000","0000","0000","0000","0000"],["0000","1011","1000","1100","1000","1000","1010","1100","1000","1110"],["0000","0001","0110","0000","0000","0010","0000","0000","0000","0101"],["0000","0001","0000","0000","0000","0000","0100","0100","0000","0100"],["0000","0011","0100","0000","0010","0000","0011","0000","0000","0110"],["0000","0001","0000","0000","0010","0000","0010","0100","0000","0100"],["0000","0001","0000","0000","0100","0100","0000","0010","0000","0110"],["0000","0001","1001","0010","0000","0010","0000","0000","0000","0100"],["0000","0011","0000","0000","0010","0100","0000","0000","0010","0100"],["0000","0011","0010","0010","0110","0010","0010","0010","0110","0110"]];
- myMap7 = [["0000","0000","0000","0000","0000","0000"],["0000","1011","1100","1000","1010","1100"],["0000","0001","0000","0000","0100","0100"],["0000","0101","0100","0010","0000","0100"],["0000","0001","0000","0000","0000","0110"],["0000","0111","0010","0110","0010","0110"]];
- myMap8 = [["0000","0000","0000","0000","0000","0000"],["0000","1011","1000","1010","1100","1100"],["0000","0001","0000","0100","0000","0100"],["0000","0101","0000","0010","0000","0110"],["0000","0011","0000","0001","0010","0110"],["0000","0011","0010","0010","0010","0110"]];
- myMap9 = [["0000","0000","0000","0000","0000","0000","0000"],["0000","1011","1100","1000","1010","1110"],["0000","0101","0000","0000","0010","0100"],["0000","0001","0010","0000","0000","0110"],["0000","0001","0100","0100","0010","0100"],["0000","0111","0010","0010","0010","0110"]];
- myMap10 = [["0000","0000","0000","0000","0000","0000","0000","0000"],["0000","1101","1000","1100","1000","1000","1100"],["0000","0011","0000","0010","0100","0000","0110"],["0000","0101","0000","0000","0000","0000","0100"],["0000","0011","0000","0000","0011","0000","0111"],["0000","0001","0000","0010","0000","0000","0100"],["0000","0111","0010","0010","0110","0010","0110"]];
- myMap11 = [["0000","0000","0000","0000","0000","0000","0000","0000","0000"],["0000","1001","1010","1100","1000","1000","1000","1110","1100"],["0000","0001","0000","0000","0000","0100","0000","0000","0100"],["0000","0001","0000","0000","0000","0000","0000","0110","0100"],["0000","0111","0100","1000","0000","0000","0000","0000","0110"],["0000","0001","0000","0000","0110","0000","0100","0000","0100"],["0000","0001","0000","0000","0000","0010","0000","0000","0110"],["0000","0001","0000","0010","0000","0010","0000","0000","0100"],["0000","0111","0010","0010","0010","0010","0110","0010","0110"]];
- myExit1 = [[5,5]];
- myExit2 = [[4,4]];
- myExit3 = [[6,3]];
- myExit4 = [[7,5]];
- myExit5 = [[3,6]];
- myExit6 = [[4,6]];
- myExit7 = [[1,1],[5,5],[5,1],[1,5],[3,3]];
- myExit8 = [[1,2],[1,4],[2,5],[2,1],[4,1],[4,5],[5,2],[5,4]];
- myExit9 = [[1,1],[5,1],[5,5],[1,5],[2,2],[4,2],[2,4],[4,4]];
- myExit10 = [[1,2],[4,1],[1,5],[4,6],[6,5],[6,4]];
- myExit11 = [[2,1],[6,1],[8,1],[4,2],[7,3],[1,4],[3,4],[5,4],[7,5],[2,6],[4,6],[5,7],[1,8],[3,8],[7,8]];
- moveRight = moveLeft = moveDown = moveUp = false;
- playGame = true;
- w = 0;
- ex = 0;
- myMap = _root["myMap" + level];
- myExit = _root["myExit" + level];
- myText = "Level: " + level;
- buildMap(myMap,myExit);
- doLevel(level);
- stop();
-