Frame 1
stop();
var dummy_mc = _root.createEmptyMovieClip("loadclip", 0);
dummy_mc.onEnterFrame = function () {
if ((_root.getBytesLoaded() > 0) and (_root.getBytesLoaded() == _root.getBytesTotal())) {
dummy_mc.removeMovieClip();
gotoAndStop ("Mainmenu");
}
loadmask_mc._xscale = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
};
Frame 2
function loadlevel(levelname) {
var _local2 = new Maze();
var _local5 = false;
var _local3 = true;
switch (levelname) {
case "dummy1" :
sizex = 3;
sizey = 3;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 9, 9, 9], [9, 0, 0, 9], [9, 9, 9, 9]];
wallsh = [[9, 9, 9], [0, 9, 0], [0, 9, 0], [9, 9, 6]];
break;
case "dummy2" :
sizex = 5;
sizey = 3;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 0, 0, 0, 0, 9], [9, 9, 9, 9, 9, 9], [9, 0, 0, 0, 0, 9]];
wallsh = [[9, 9, 9, 9, 9], [0, 0, 0, 0, 9], [0, 9, 0, 9, 0], [9, 9, 9, 9, 6]];
break;
case "pyramid" :
sizex = 9;
sizey = 5;
startx = 8;
starty = 0;
starrdir = 3;
wallsv = [[9, 0, 9, 0, 0, 0, 9, 0, 0, 9], [9, 9, 0, 0, 9, 0, 0, 0, 9, 9], [9, 0, 9, 0, 0, 0, 0, 9, 0, 9], [9, 0, 0, 9, 0, 9, 9, 0, 0, 9], [9, 0, 0, 0, 9, 9, 0, 0, 0, 9]];
wallsh = [[9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 0, 9, 9, 0, 9, 0, 9, 9], [0, 9, 0, 9, 0, 9, 9, 9, 0], [0, 0, 9, 0, 9, 0, 9, 0, 0], [0, 0, 0, 9, 0, 9, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 0]];
break;
case "zig" :
sizex = 5;
sizey = 5;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 9, 0, 0, 0, 6], [9, 0, 9, 0, 9, 9], [9, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 9], [9, 9, 0, 0, 0, 9]];
wallsh = [[9, 9, 9, 9, 9], [0, 9, 0, 9, 9], [9, 0, 9, 0, 0], [0, 9, 0, 9, 0], [0, 0, 9, 0, 0], [6, 9, 9, 9, 9]];
break;
case "zag" :
sizex = 4;
sizey = 5;
startx = 4;
starty = 5;
startdir = 3;
wallsv = [[9, 0, 0, 9, 9], [9, 0, 9, 0, 9], [9, 9, 0, 9, 9], [9, 0, 9, 0, 9], [9, 9, 0, 0, 9]];
wallsh = [[9, 9, 9, 9], [0, 9, 0, 0], [0, 0, 9, 0], [0, 9, 9, 0], [0, 9, 0, 9], [6, 9, 9, 9]];
break;
case "level1" :
sizex = 9;
sizey = 9;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 9, 0, 0, 0, 0, 0, 9, 9, 9], [9, 0, 9, 9, 9, 0, 9, 9, 0, 9], [9, 0, 0, 9, 0, 9, 0, 0, 9, 9], [9, 9, 9, 9, 0, 9, 9, 9, 0, 9], [9, 0, 0, 0, 0, 0, 0, 0, 9, 9], [9, 9, 9, 0, 0, 0, 0, 9, 0, 9], [9, 0, 0, 9, 9, 9, 0, 0, 0, 9], [9, 0, 9, 0, 0, 0, 9, 0, 9, 9], [9, 0, 0, 0, 9, 9, 0, 9, 0, 9]];
wallsh = [[9, 9, 9, 9, 9, 9, 9, 9, 9], [0, 0, 0, 0, 0, 9, 0, 0, 0], [9, 9, 0, 0, 9, 0, 9, 0, 9], [9, 0, 9, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 0, 0, 9, 9], [0, 0, 0, 9, 9, 9, 9, 0, 0], [0, 9, 9, 9, 0, 9, 0, 9, 9], [9, 9, 9, 0, 0, 9, 9, 9, 0], [0, 9, 0, 9, 0, 0, 0, 0, 9], [9, 9, 9, 9, 9, 9, 9, 9, 6]];
break;
case "level2" :
sizex = 13;
sizey = 3;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 9, 0, 0, 9, 0, 9, 0, 9, 9, 9, 0, 0, 6], [9, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 9, 9, 9], [9, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 9, 0, 9]];
wallsh = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [0, 0, 9, 9, 0, 9, 9, 0, 0, 0, 0, 0, 9], [9, 9, 0, 0, 0, 9, 9, 9, 0, 9, 0, 0, 0], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]];
break;
case "level3" :
break;
case "level4" :
sizex = 90;
sizey = 9;
startx = 5;
starty = 0;
startdir = 0;
wallsv = [[9, 0, 0, 9, 0, 0, 9, 0, 0, 0, 9], [9, 9, 0, 9, 0, 0, 0, 0, 9, 0, 9], [9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9], [9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9], [9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 9], [9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 9], [9, 0, 9, 0, 0, 9, 0, 0, 0, 9, 9], [9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 9], [9, 0, 0, 0, 0, 0, 9, 0, 0, 0, 9]];
wallsh = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [0, 0, 9, 9, 9, 0, 9, 0, 9, 0], [0, 0, 0, 9, 9, 9, 9, 0, 0, 0], [0, 9, 0, 9, 9, 0, 9, 0, 0, 9], [0, 0, 9, 0, 0, 9, 9, 0, 0, 0], [0, 9, 0, 0, 9, 9, 0, 9, 0, 0], [0, 0, 0, 9, 9, 9, 0, 0, 0, 0], [0, 0, 9, 0, 9, 9, 9, 9, 0, 9], [9, 9, 0, 9, 9, 9, 9, 9, 9, 0], [9, 9, 9, 9, 6, 9, 9, 9, 9, 9]];
break;
case "level5" :
sizex = 5;
sizey = 16;
startx = 3;
starty = 0;
startdir = 0;
wallsv = [[9, 0, 0, 0, 0, 9], [9, 0, 0, 0, 9, 9], [9, 0, 9, 9, 0, 9], [9, 9, 0, 0, 9, 9], [9, 9, 0, 0, 9, 9], [9, 0, 0, 9, 0, 9], [9, 0, 9, 0, 9, 9], [9, 9, 9, 0, 0, 9], [9, 0, 9, 9, 0, 9], [9, 9, 0, 0, 9, 9], [9, 0, 9, 9, 0, 9], [9, 0, 0, 0, 0, 9], [9, 9, 0, 9, 9, 9], [9, 0, 9, 0, 0, 9], [9, 0, 0, 9, 0, 9], [9, 9, 9, 0, 9, 9]];
wallsh = [[9, 9, 9, 9, 9], [0, 9, 0, 9, 0], [9, 9, 0, 0, 9], [0, 0, 9, 0, 0], [0, 9, 9, 0, 0], [0, 9, 9, 9, 0], [9, 0, 0, 9, 0], [0, 9, 0, 9, 9], [9, 0, 9, 0, 9], [0, 0, 0, 0, 0], [0, 9, 9, 9, 0], [0, 9, 0, 9, 9], [0, 9, 9, 0, 0], [9, 0, 0, 9, 0], [0, 9, 9, 0, 9], [0, 0, 0, 9, 0], [9, 9, 6, 9, 9]];
break;
case "open" :
sizex = 2;
sizey = 2;
startx = 0;
starty = 0;
startdir = 0;
wallsv = [[9, 0, 9], [9, 0, 9]];
wallsh = [[9, 9, 9], [0, 0, 0], [6, 6, 6]];
}
if (_local3) {
_local2.sizex = sizex;
_local2.sizey = 1;
_local2.sizez = sizey;
_local2.wallsh = Array(wallsh);
_local2.wallsv = Array(wallsv);
_local2.playerx = startx;
_local2.playery = 0;
_local2.playerz = starty;
_local2.playerdir = startdir;
_local2.levelname = levelname;
} else {
_local2.sizex = sizex;
_local2.sizey = sizey;
_local2.sizez = sizez;
_local2.wallsh = wallsh;
_local2.wallsv = wallsv;
_local2.playerx = startx;
_local2.playery = starty;
_local2.playerz = startz;
_local2.playerdir = startdir;
_local2.levelname = levelname;
}
_global.gotmap = _local5;
return((_global.maze = _local2));
}
_global.levellist = Array();
Frame 4
_root.nextLevel_btn._visible = _global.levellist.length > 0;
Frame 7
function win() {
gotoAndStop ("win");
}
_root.framed_hall.hall.viewangle = (Math.PI/2);
_root.framed_hall.setSize(378, 216);
_global.maze.addListner(_root.framed_hall.hall);
_root.framed_hall.hall.redraw();
Symbol 12 Button
on (release) {
loadlevel("dummy1");
with (_global.levellist) {
push("level5");
push("level4");
push("level2");
push("pyramid");
push("level1");
push("dummy2");
}
gotoAndStop (7);
}
Symbol 16 Button
on (release) {
gotoAndStop ("credits");
}
Symbol 53 MovieClip [__Packages.Maze] Frame 0
class Maze
{
var playerdir, playerz, playerx, playery, wallsh, wallsv;
function Maze () {
}
function addListner(listner) {
listner.maze = this;
listners.push(listner);
}
function turn(dir) {
var _local2;
playerdir = playerdir + dir;
if (playerdir < 0) {
playerdir = playerdir + 4;
}
playerdir = playerdir % 4;
for (_local2 in listners) {
listners[_local2].rotation();
}
updateAfterEvent();
}
function move(dir) {
var _local3;
var _local5;
_local5 = getrelwall(((dir == -1) ? 0 : 1), 0, 0);
if (_local5 & 4) {
_root.win();
} else {
if (_local5 & 8) {
return(false);
}
switch (playerdir) {
case 0 :
playerz = playerz + dir;
break;
case 1 :
playerx = playerx + dir;
break;
case 2 :
playerz = playerz - dir;
break;
case 3 :
playerx = playerx - dir;
break;
}
for (_local3 in listners) {
listners[_local3].movement();
}
updateAfterEvent();
return(true);
}
}
function getrelwall(deep, dir, sidestep, y) {
var _local6;
var _local8;
var _local3;
var _local2;
var _local4;
y = y + playery;
if (dir <= -1) {
dir = 4 + dir;
}
_local8 = (dir + playerdir) % 4;
switch (playerdir) {
case 0 :
_local3 = playerx + sidestep;
_local2 = playerz + (deep - 1);
break;
case 1 :
_local3 = playerx + (deep - 1);
_local2 = playerz - sidestep;
break;
case 2 :
_local3 = playerx - sidestep;
_local2 = playerz - (deep - 1);
break;
case 3 :
_local3 = playerx - (deep - 1);
_local2 = playerz + sidestep;
break;
}
switch (_local8) {
case 0 :
_local2 = _local2 + 1;
break;
case 1 :
_local3 = _local3 + 1;
break;
case 2 :
break;
case 3 :
break;
}
if ((_local8 % 2) == 0) {
_local6 = wallsh;
} else {
_local6 = wallsv;
}
_local4 = _local6[y][_local2][_local3];
return(_local4);
}
var listners = Array();
}
Symbol 54 MovieClip [__Packages.Framed_Hall] Frame 0
class Framed_Hall extends MovieClip
{
var hall;
function Framed_Hall () {
super();
}
function setSize(w, h) {
hall.setSize(w, h);
}
}
Symbol 55 MovieClip [__Packages.Mazelistner] Frame 0
interface Mazelistner
{
}
Symbol 56 MovieClip [__Packages.Hall] Frame 0
class Hall extends MovieClip implements Mazelistner
{
var width, heigth, d, viewangle, ar, cubesize, clear, lineStyle, maze, beginFill, moveTo, lineTo, endFill;
function Hall () {
super();
}
function setSize(w, h) {
width = w;
heigth = h;
d = (w / 2) * Math.tan(viewangle / 2);
ar = 1;
cubesize = w;
}
function rotation() {
redraw();
}
function movement() {
redraw();
}
function redraw() {
var _local3;
var _local5;
var _local2;
var _local4;
var _local7;
var _local6;
clear();
lineStyle(0, 0);
var _local8 = 7;
switch (maze.playerdir) {
case 0 :
_local3 = Math.min(_local8, maze.sizez - maze.playerz);
break;
case 1 :
_local3 = Math.min(_local8, maze.sizex - maze.playerx);
break;
case 2 :
_local3 = Math.min(_local8, maze.playerz + 1);
break;
case 3 :
_local3 = Math.min(_local8, maze.playerx + 1);
}
while (_local3 > 0) {
_local5 = Math.ceil((_local3 + 1.5) * Math.tan(viewangle / 2));
switch (maze.playerdir) {
case 0 :
_local7 = -Math.min(_local5, maze.playerx + 1);
_local6 = Math.min(_local5, (maze.sizex - maze.playerx) + 1);
break;
case 1 :
_local7 = -Math.min(_local5, maze.playerz + 1);
_local6 = Math.min(_local5, (maze.sizez - maze.playerz) + 1);
break;
case 2 :
_local7 = -Math.min(_local5, (maze.sizex - maze.playerx) + 1);
_local6 = Math.min(_local5, maze.playerx + 1);
break;
case 3 :
_local7 = -Math.min(_local5, (maze.sizez - maze.playerz) + 1);
_local6 = Math.min(_local5, maze.playerz + 1);
}
_local2 = _local7;
while (_local2 <= _local6) {
_local4 = maze.getrelwall(_local3, 0, _local2, 0);
if (_local4 & 1) {
drawFace(_local3, _local2, 3, wallcolor);
} else if (_local4 & 2) {
drawFace(_local3, _local2, 3, exitcolor);
}
_local2++;
}
_local2 = -_local5;
while (_local2 <= _local5) {
drawFace(_local3, _local2, 2, topcolor);
drawFace(_local3, _local2, -2, bottomcolor);
_local4 = maze.getrelwall(_local3, -1, _local2, 0);
if (_local4 & 1) {
drawFace(_local3, _local2, -1, wallcolor);
} else if (_local4 & 2) {
drawFace(_local3, _local2, -1, exitcolor);
}
_local4 = maze.getrelwall(_local3, 1, _local2, 0);
if (_local4 & 1) {
drawFace(_local3, _local2, 1, wallcolor);
} else if (_local4 & 2) {
drawFace(_local3, _local2, 1, exitcolor);
}
_local2++;
}
_local3--;
}
}
function drawFace(deep, sidestep, dir, color) {
var _local5;
var _local8;
var _local6;
var _local7;
var _local4;
var _local3;
_local4 = (sidestep - 0.5) * cubesize;
_local3 = (sidestep + 0.5) * cubesize;
switch (dir) {
case 0 :
_local5 = convert3dTo2d(_local4, cubesize * -0.5, (deep - 0.5) * cubesize);
_local8 = convert3dTo2d(_local4, cubesize * 0.5, (deep - 0.5) * cubesize);
_local6 = convert3dTo2d(_local3, cubesize * 0.5, (deep - 0.5) * cubesize);
_local7 = convert3dTo2d(_local3, cubesize * -0.5, (deep - 0.5) * cubesize);
break;
case 3 :
_local5 = convert3dTo2d(_local4, cubesize * -0.5, (deep + 0.5) * cubesize);
_local8 = convert3dTo2d(_local4, cubesize * 0.5, (deep + 0.5) * cubesize);
_local6 = convert3dTo2d(_local3, cubesize * 0.5, (deep + 0.5) * cubesize);
_local7 = convert3dTo2d(_local3, cubesize * -0.5, (deep + 0.5) * cubesize);
break;
case -1 :
_local5 = convert3dTo2d(_local4, cubesize * -0.5, (deep - 0.5) * cubesize);
_local8 = convert3dTo2d(_local4, cubesize * 0.5, (deep - 0.5) * cubesize);
_local6 = convert3dTo2d(_local4, cubesize * 0.5, (deep + 0.5) * cubesize);
_local7 = convert3dTo2d(_local4, cubesize * -0.5, (deep + 0.5) * cubesize);
break;
case 1 :
_local5 = convert3dTo2d(_local3, cubesize * -0.5, (deep - 0.5) * cubesize);
_local8 = convert3dTo2d(_local3, cubesize * 0.5, (deep - 0.5) * cubesize);
_local6 = convert3dTo2d(_local3, cubesize * 0.5, (deep + 0.5) * cubesize);
_local7 = convert3dTo2d(_local3, cubesize * -0.5, (deep + 0.5) * cubesize);
break;
case -2 :
_local5 = convert3dTo2d(_local4, cubesize * -0.5, (deep - 0.5) * cubesize);
_local8 = convert3dTo2d(_local4, cubesize * -0.5, (deep + 0.5) * cubesize);
_local6 = convert3dTo2d(_local3, cubesize * -0.5, (deep + 0.5) * cubesize);
_local7 = convert3dTo2d(_local3, cubesize * -0.5, (deep - 0.5) * cubesize);
break;
case 2 :
_local5 = convert3dTo2d(_local4, cubesize * 0.5, (deep - 0.5) * cubesize);
_local8 = convert3dTo2d(_local4, cubesize * 0.5, (deep + 0.5) * cubesize);
_local6 = convert3dTo2d(_local3, cubesize * 0.5, (deep + 0.5) * cubesize);
_local7 = convert3dTo2d(_local3, cubesize * 0.5, (deep - 0.5) * cubesize);
}
beginFill(color);
moveTo(_local5.x, _local5.y);
lineTo(_local8.x, _local8.y);
lineTo(_local6.x, _local6.y);
lineTo(_local7.x, _local7.y);
lineTo(_local5.x, _local5.y);
endFill();
}
function convert3dTo2d(x, y, z) {
z = Math.max(0, z);
return({x:(width * 0.5) + ((d * x) / z), y:(heigth * 0.5) + (((d * (-y)) * ar) / z)});
}
var wallcolor = 12632256;
var exitcolor = 12303359;
var topcolor = 14612722;
var bottomcolor = 10066329;
}
Symbol 24 Button
on (release) {
gotoAndStop ("mainmenu");
}
Symbol 26 Button
on (release) {
nextlevel = _global.levellist.pop();
loadlevel(nextlevel);
gotoAndStop (7);
}
Symbol 30 Button
on (release) {
gotoAndStop ("mainmenu");
}
Symbol 38 Button
on (release, keyPress "<Up>") {
_global.maze.move(1);
}
Symbol 40 Button
on (release, keyPress "<Down>") {
_global.maze.move(-1);
}
Symbol 42 Button
on (release, keyPress "<Left>") {
_global.maze.turn(-1);
}
Symbol 44 Button
on (release, keyPress "<Right>") {
_global.maze.turn(1);
}
Symbol 47 Button
on (release) {
gotoAndStop ("mainmenu");
}
Symbol 50 MovieClip [Hall] Frame 1
#initclip 6
Object.registerClass("Hall", Hall);
#endinitclip
Symbol 52 MovieClip [Framed Hall] Frame 1
#initclip 5
Object.registerClass("Framed Hall", Framed_Hall);
#endinitclip