Frame 1
fscommand ("allowscale", false);
_global.findPath = function (map, startY, startX, endY, endX) {
var HV_COST = 10;
var D_COST = 14;
var ALLOW_DIAGONAL = false;
var ALLOW_DIAGONAL_CORNERING = true;
isOpen = function (y, x) {
return(mapStatus[y][x].open);
};
isClosed = function (y, x) {
return(mapStatus[y][x].closed);
};
nearerSquare = function () {
var minimum = 999999;
var indexFound = 0;
var _local2;
var _local3;
var _local1 = openList.length;
while ((_local1--) > 0) {
_local3 = mapStatus[openList[_local1][0]][openList[_local1][1]];
_local2 = _local3.heuristic + _local3.movementCost;
if (_local2 <= minimum) {
minimum = _local2;
indexFound = _local1;
}
}
return(indexFound);
};
closeSquare = function (y, x) {
var _local3 = y;
var _local2 = openList.length;
var _local1 = 0;
while (_local1 < _local2) {
if (openList[_local1][0] == _local3) {
if (openList[_local1][1] == x) {
openList.splice(_local1, 1);
break;
}
}
_local1++;
}
mapStatus[_local3][x].open = false;
mapStatus[_local3][x].closed = true;
};
openSquare = function (y, x, parent, movementCost, heuristic, replacing) {
var _local1 = y;
var _local2 = x;
if (!replacing) {
openList.push([_local1, _local2]);
mapStatus[_local1][_local2] = {heuristic:heuristic, open:true, closed:false};
}
mapStatus[_local1][_local2].parent = parent;
mapStatus[_local1][_local2].movementCost = movementCost;
};
var mapH = map.length;
var mapW = map[0].length;
var mapStatus = new Array();
var i = 0;
while (i < mapH) {
mapStatus[i] = new Array();
i++;
}
if ((startY == undefined) || (startX == undefined)) {
return(null);
}
if ((endY == undefined) || (endX == undefined)) {
return(null);
}
var openList = new Array();
openSquare(startY, startX, undefined, 0);
while ((openList.length > 0) && (!isClosed(endY, endX))) {
var i = nearerSquare();
var nowY = openList[i][0];
var nowX = openList[i][1];
closeSquare(nowY, nowX);
var _local2 = nowY - 1;
while (_local2 < (nowY + 2)) {
var _local1 = nowX - 1;
while (_local1 < (nowX + 2)) {
if (((((((_local2 >= 0) && (_local2 < mapH)) && (_local1 >= 0)) && (_local1 < mapW)) && (!((_local2 == nowY) && (_local1 == nowX)))) && ((ALLOW_DIAGONAL || (_local2 == nowY)) || (_local1 == nowX))) && (((ALLOW_DIAGONAL_CORNERING || (_local2 == nowY)) || (_local1 == nowX)) || ((map[_local2][nowX] != 0) && (map[nowY][_local1])))) {
if (map[_local2][_local1] != 0) {
if (!isClosed(_local2, _local1)) {
var _local3 = mapStatus[nowY][nowX].movementCost + ((((_local2 == nowY) || (_local1 == nowX)) ? (HV_COST) : (D_COST)) * map[_local2][_local1]);
if (isOpen(_local2, _local1)) {
if (_local3 < mapStatus[_local2][_local1].movementCost) {
openSquare(_local2, _local1, [nowY, nowX], _local3, undefined, true);
}
} else {
var heuristic = ((Math.abs(_local2 - endY) + Math.abs(_local1 - endX)) * 10);
openSquare(_local2, _local1, [nowY, nowX], _local3, heuristic, false);
}
}
}
}
_local1++;
}
_local2++;
}
}
var pFound = isClosed(endY, endX);
delete isOpen;
delete isClosed;
delete nearerSquare;
delete closeSquare;
delete openSquare;
if (pFound) {
var returnPath = new Array();
var nowY = endY;
var nowX = endX;
while ((nowY != startY) || (nowX != startX)) {
returnPath.push([nowY, nowX]);
var newY = mapStatus[nowY][nowX].parent[0];
var newX = mapStatus[nowY][nowX].parent[1];
nowY = newY;
nowX = newX;
}
returnPath.push([startY, startX]);
return(returnPath);
}
return(null);
};
ASSetPropFlags(_global, "findPath", 1, 0);
playing = 0;
klik = new Sound(_root.mySound);
klik.attachSound("klik");
wipe = new Sound(_root.mySound);
wipe.attachSound("wipe");
error = new Sound(_root.mySound);
error.attachSound("error");
blip = new Sound(_root.mySound);
blip.attachSound("blip");
stopAllSounds();
stop();
Instance of Symbol 25 MovieClip in Frame 1
onClipEvent (enterFrame) {
text = ((int(_parent.getBytesLoaded() / 1000) add " OF ") add int(_parent.getBytesTotal() / 1000)) add " LOADED ...";
if (_parent.getBytesTotal() == _parent.getBytesLoaded()) {
_root.goButton._x = 125;
}
}
Frame 2
function buildMap(map) {
var _local3 = this;
mapWidth = map[0].length;
mapHeight = map.length;
var _local2 = 0;
while (_local2 < mapHeight) {
var _local1 = 0;
while (_local1 < mapWidth) {
_local3.attachMovie("tile", (("t_" + _local2) + "_") + _local1, ++d);
t = _local3[(("t_" + _local2) + "_") + _local1];
t._x = _local1 * tileW;
t._y = _local2 * tileH;
t.gotoAndStop(map[_local2][_local1]);
t.shapePos = null;
t.x = _local1;
t.y = _local2;
_local1++;
}
_local2++;
}
duplicateMovieClip ("tempTile", "temp", ++d);
duplicateMovieClip ("tempTar", "tar", ++d);
temp._x = -100;
temp._y = -100;
tar._x = -100;
tar._y = -100;
timerID = setInterval(gameTime, tc);
}
function addTiles(cn) {
var _local1 = cn;
var _local2 = _root;
while (_local1 >= 0) {
cx = int(random(10));
cy = int(random(10));
t = _local2[(("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;
_local1--;
}
}
}
function findTile(y, x) {
var _local1 = y;
var _local2 = x;
var _local3 = _root;
s = _local3[(("t_" + _local1) + "_") + _local2].shapePos;
if ((_local3[(("t_" + (_local1 - 1)) + "_") + _local2].shapePos == s) or (_local3[(("t_" + (_local1 + 1)) + "_") + _local2].shapePos == s)) {
_local3[(("t_" + _local1) + "_") + _local2].gotoAndPlay(3);
_local3[(("t_" + _local1) + "_") + _local2].shapePos = null;
myMap[_local1][_local2] = 1;
sc++;
if (_local3[(("t_" + (_local1 - 1)) + "_") + _local2].shapePos == s) {
findTile(_local1 - 1, _local2);
}
if (_local3[(("t_" + (_local1 + 1)) + "_") + _local2].shapePos == s) {
findTile(_local1 + 1, _local2);
}
}
if (_local3[(("t_" + (_local1 - 1)) + "_") + _local2].shapePos == s) {
_local3[(("t_" + (_local1 - 1)) + "_") + _local2].gotoAndPlay(3);
_local3[(("t_" + (_local1 - 1)) + "_") + _local2].shapePos = null;
myMap[_local1 - 1][_local2] = 1;
sc++;
}
if (_local3[(("t_" + (_local1 + 1)) + "_") + _local2].shapePos == s) {
_local3[(("t_" + (_local1 + 1)) + "_") + _local2].gotoAndPlay(3);
_local3[(("t_" + (_local1 + 1)) + "_") + _local2].shapePos = null;
myMap[_local1 + 1][_local2] = 1;
sc++;
}
}
function addScore() {
if (sc > 0) {
score = score + (sc * 100);
frame = sc * 35;
textClip.gotoAndPlay(frame);
wipe.start(0, 1);
}
}
function countTiles() {
var _local3 = 0;
var _local2 = 0;
while (_local2 < mapHeight) {
var _local1 = 0;
while (_local1 < mapWidth) {
if (_root[(("t_" + _local2) + "_") + _local1].shapePos != null) {
_local3++;
}
_local1++;
}
_local2++;
}
return(_local3);
}
function gameTime() {
var _local1 = _root;
bar._height = barHeight--;
if ((bar._height <= 0) and (_local1.playGame == true)) {
var _local2 = _local1.countTiles();
l++;
if (_local2 < 96) {
barHeight = 50;
_local1.blip.start(0, 1);
_local1.addTiles(4);
if (l == 12) {
l = 0;
level++;
clearInterval(timerID);
if (tc > 30) {
tc--;
}
timerID = setInterval(gameTime, tc);
}
} else {
clearInterval(timerID);
_local1.playGame = false;
_local1.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();
Instance of Symbol 53 MovieClip "tempTar" in Frame 2
onClipEvent (load) {
if (this._name != "tar") {
this._alpha = 0;
}
}
Instance of Symbol 54 MovieClip "tempTile" in Frame 2
onClipEvent (load) {
if (this._name != "temp") {
this._alpha = 0;
}
stop();
_root.c = 1;
}
onClipEvent (enterFrame) {
if (this._name == "temp") {
if (_root.moveTemp == true) {
this._x = _root.movX[_root.c] * 28;
this._y = _root.movY[_root.c] * 28;
_root.c++;
if (_root.c >= _root.counter) {
_root.moveTemp = false;
_root.c = 1;
this._x = -200;
_root[(("t_" + _root.lastY) + "_") + _root.lastX].gotoAndStop(2);
_root[(("t_" + _root.lastY) + "_") + _root.lastX].shape.gotoAndStop(_root.tpos);
_root[(("t_" + _root.lastY) + "_") + _root.lastX].shapePos = _root.tpos;
_root.myMap[_root.lastY][_root.lastX] = 0;
_root.sc = 0;
_root.findTile(_root.lastY, _root.lastX);
_root.addScore();
_root.playGame = true;
}
}
}
}
Instance of Symbol 88 MovieClip "bar" in Frame 2
onClipEvent (load) {
this._height = 50;
}
Frame 3
var i = 0;
while (i < mapHeight) {
var j = 0;
while (j < mapWidth) {
removeMovieClip(_root[(("t_" + i) + "_") + j]);
j++;
}
i++;
}
removeMovieClip(temp);
removeMovieClip(tar);
stop();
Symbol 12 MovieClip Frame 1
stop();
Symbol 14 Button
on (press) {
if (_root.playGame) {
if (this.shapePos != null) {
_root.tar.swapDepths(++_root.d);
_root.tar._x = this._x;
_root.tar._y = this._y;
_root.tx = this.x;
_root.ty = this.y;
_root.tpos = this.shapePos;
_root.hit = true;
_root.klik.start(0, 1);
}
if ((this.shapePos == null) and _root.hit) {
_root.playGame = false;
_root.hit = false;
_root.tar._x = -150;
fpath = findPath(_root.myMap, _root.ty, _root.tx, this.y, this.x);
if (fpath != null) {
fpath.reverse();
_root.counter = fpath.length;
i = 0;
while (i < fpath.length) {
_root.movX[i] = fpath[i][1];
_root.movY[i] = fpath[i][0];
i++;
}
this.empty.gotoAndStop(_root.tpos + 1);
_root.temp.gotoAndStop(2);
_root.temp.shape.gotoAndStop(_root.tpos);
_root.temp.swapDepths(2000 + (++d));
_root.temp._x = _root.movX[0] * 28;
_root.temp._y = _root.movY[0] * 28;
_root.myMap[_root.ty][_root.tx] = 1;
_root[(("t_" + _root.ty) + "_") + _root.tx].gotoAndStop(1);
_root[(("t_" + _root.ty) + "_") + _root.tx].shapePos = null;
_root.lastX = this.x;
_root.lastY = this.y;
_root.moveTemp = true;
}
if (fpath == null) {
_root.error.start(0, 1);
_root.playGame = true;
}
}
}
}
Symbol 22 MovieClip [tile] Frame 10
gotoAndStop (1);
Symbol 31 Button
on (press) {
nextFrame();
}
Symbol 54 MovieClip Frame 1
stop();
Symbol 59 Button
on (press) {
getURL ("http://www.freestuff.gr/lightforce", "_blank");
}
Symbol 62 Button
on (release) {
if (_root.playing == 1) {
stopAllSounds();
loopSound.gotoAndStop("Stop");
playing = 0;
} else {
loopSound.gotoAndStop("Play");
playing = 1;
}
}
Symbol 84 MovieClip Frame 1
stop();
Symbol 84 MovieClip Frame 99
stop();
Symbol 84 MovieClip Frame 136
stop();
Symbol 84 MovieClip Frame 170
stop();
Symbol 84 MovieClip Frame 205
stop();
Symbol 84 MovieClip Frame 240
stop();
Symbol 84 MovieClip Frame 275
stop();
Symbol 84 MovieClip Frame 310
stop();
Symbol 84 MovieClip Frame 345
stop();
Symbol 84 MovieClip Frame 380
stop();
Symbol 86 MovieClip Frame 1
stop();
Symbol 98 Button
on (press) {
gotoAndPlay (1);
}