Frame 1
_root.victory = 0;
_root.screen.removeMovieClip();
play();
Frame 3
if (_root.getBytesLoaded() >= _root.getBytesTotal()) {
gotoAndPlay ("Game");
}
Frame 4
gotoAndPlay ("preload");
Instance of Symbol 9 MovieClip "master" in Frame 5
onClipEvent (keyDown) {
if (Key.getCode() == 37) {
input = 1;
}
if (Key.getCode() == 39) {
input = 2;
}
if (Key.getCode() == 38) {
input = 3;
}
if (Key.getCode() == 40) {
input = 4;
}
if (Key.getCode() == 65) {
input = 5;
}
if (Key.getCode() == 83) {
input = 6;
}
if (Key.getCode() == 187) {
input = 7;
}
}
onClipEvent (enterFrame) {
function getinput() {
}
function at(dist) {
var _local2 = _root.map[_root.pos + dist];
if (_local2 == undefined) {
_local2 = 0;
}
return(_local2);
}
function canmove(dist) {
return(at(dist) != 1);
}
function isspikes(dist) {
return(at(dist) == 2);
}
function isfallthru(dist) {
var _local1 = at(dist);
return((_local1 == 0) || (_local1 == 4));
}
function isblank(dist) {
return(at(dist) == 0);
}
function isladder(dist) {
return(at(dist) == 3);
}
function candropthru(dist) {
return(at(dist) >= 3);
}
function isdoor(dist) {
return(at(dist) == 6);
}
function _move(dist) {
_root.pos = _root.pos + dist;
}
function playgame() {
if (delay) {
unchanged = 1;
}
while (!delay) {
if (dead) {
if (deathtimer > 0) {
deathtimer--;
delay = 1;
}
if (deathtimer <= 0) {
_root.pos = _root.pos0;
dead = 0;
falling = 0;
jump = 0;
}
} else if (jump) {
if (jump >= 4) {
if (canmove(-12)) {
_move(-12);
jump--;
} else {
jump = 0;
}
} else if (canmove(jumpdir)) {
_move(jumpdir);
jump--;
} else {
jump = 0;
}
if (jump == 0) {
if (isblank(12)) {
falling = 1;
}
}
delay = _delay;
} else if (falling) {
if (isspikes(12)) {
dead = 1;
deathtimer = 8;
delay = _delay * 2;
} else if (isfallthru(12)) {
_move(12);
delay = _delay;
} else {
falling = 0;
delay = _delay;
}
} else {
if (input == 1) {
if (canmove(-1)) {
_move(-1);
}
if (isblank(12)) {
falling = 1;
}
delay = _delay;
} else if (input == 2) {
if (canmove(1)) {
_move(1);
}
if (isblank(12)) {
falling = 1;
}
delay = _delay;
} else if (input == 3) {
if (isladder(0)) {
if (canmove(-12)) {
_move(-12);
}
delay = _delay;
}
if (isdoor(0)) {
_root.levelnumber++;
loadmap(_root.levelnumber);
delay = _delay;
}
} else if (input == 4) {
keydown = 0;
if (candropthru(12)) {
_move(12);
if (isblank(12)) {
falling = 1;
}
delay = _delay;
}
} else if (input == 5) {
jump = 5;
jumpdir = -1;
} else if (input == 6) {
jump = 5;
jumpdir = 1;
} else if (input == 7) {
_root.levelnumber++;
loadmap(_root.levelnumber);
} else {
unchanged = 1;
}
input = 0;
delay = 1;
}
}
if (delay) {
delay--;
return(undefined);
}
}
function init() {
jump = 0;
falling = 0;
jumpdir = 0;
dead = 0;
deathtimer = 0;
_root.victory = 0;
needsInit = 0;
initgfx();
_root.levelnumber = 0;
loadmap(_root.levelnumber);
drawmap();
delay = 1;
}
function initgfx() {
_root.screen = _root.createEmptyMovieClip("screen", this.getNextHighestDepth());
_root.screen._x = 76;
_root.screen._y = 86;
_root.bmp = new flash.display.BitmapData(288, 192, false, 0);
var _local3 = "tiles";
_root.tiles = flash.display.BitmapData.loadBitmap(_local3);
_root.screen.attachBitmap(_root.bmp, _root.getNextHighestDepth(), "always", false);
}
function destroybitmap() {
_root.screen.removeMovieClip();
}
function drawmap() {
drawpos = _root.pos - 65;
x0 = int(drawpos) % 12;
y0 = int(drawpos / 12);
drawmap2(_root.bmp, _root.tiles, 24, 24, 0, 0, _root.map, x0, y0, x0 + 12, y0 + 8);
tx = 0;
ty = 0;
var _local2 = new flash.geom.Rectangle(0, 0, 24, 24);
var _local3 = new flash.geom.Point(120, 120);
_root.bmp.copyPixels(_root.tiles, _local2, _local3);
if ((deathtimer % 2) == 1) {
_root.screen.blendMode = 9;
} else {
_root.screen.blendMode = 0;
}
}
function drawmap2(dest, tilesrc, xtilesize, ytilesize, drawx, drawy, tilemap, x0, y0, x1, y1) {
var _local2;
var _local3;
var _local11;
var _local19;
var _local1;
var _local10;
var _local9;
var _local8;
var _local22;
_local8 = tilesrc.width / xtilesize;
_local11 = x1 - x0;
_local19 = y1 - y0;
_local3 = 0;
while (_local3 < _local19) {
_local2 = 0;
while (_local2 < _local11) {
_local1 = tilemap[((_local3 + y0) * 12) + (_local2 + x0)];
if (_local1 === undefined) {
_local1 = 0;
}
_local1++;
_local10 = (_local1 % _local8) * xtilesize;
_local9 = int(_local1 / _local8) * ytilesize;
var _local5 = new flash.geom.Rectangle(_local10, _local9, xtilesize, ytilesize);
var _local7 = new flash.geom.Point((_local2 * xtilesize) + drawx, (_local3 * ytilesize) + drawy);
dest.copyPixels(tilesrc, _local5, _local7);
_local2++;
}
_local3++;
}
}
function loadmap(mapnumber) {
var _local4;
_local4 = "";
switch (mapnumber) {
case 0 :
_local4 = "F01110411031102110511001107120C1A00103012421240103012001400103012401200600010301200110245001504401E004F03004F03004F02400013002A0010220012002101120012001400200010270415004410270010014100220010301030120012001030003015011030003112022110311324103612001030180010301F030010002802100213011D00120010001F010216002A001F09001F0200150011001100100022001120120112031F00011F03001800290114012802103A00360121003201210210011000311101140031112114003F1F151FF";
break;
case 1 :
_local4 = "F1F1F121A0068021600120014021F030016001200160214021F01021F01001C001300150310001100150010031000130015001A031B002A00110027001140100021002700114015002100270011401C0021002700114012002100270011401F0100210022002100200011401200114015002100270011401F031A001721103A103118003A003A0030150012401300114017001800104014002200160012401600180010401300230013002000134013001040160020001000100014001040180018001040110015401E011902182F141FF";
break;
case 2 :
_local4 = "F0F0F0B0020001200540051001F0000110062005600150054001500160018001200110056001F01001600103217003A003A003A003A003A0017002A001D002A0017002A001700140021001700130012002A0017001400201500120110001F020015001F03001F030012001D00100017002200260012001B0018001D0210021501103118003A003F090012001F030010001F01001F022600100216001030180010301802182F131FF";
break;
case 3 :
_local4 = "204160012001F03001000190050002030430022002000220030230014002400120026001700210010290018002001200023002000104013012200104010002000210021001040170020104010220023001040110022031044110014001400105011500011011021001500100040115200104001100011014000110011001200100110001002110010001100110012001000100210001101100011001100120010011000100211001300106000120610001100110014001A02100018001101110013001040001700110011001200103311001220103504103A003F09002A00170044002A0011001301210011201301110311001100140012001003125200130012011002102000130012011000110010021100110027001120510110011000115D002000164010001000160012011002100113001300201401120115001240160418261FF";
break;
case 4 :
_local4 = "03A003A003F060C6F0100670067001D002A0011005A0041005F090220103000142410061F001F03001F090050001700120023001500510019001E0013001F03001F03001F0300170140270011001800150030190017002A00180017001000150017001300470055001000150017001300170017001F030027002100170015002000280010001B0026001000200016041100140016001B001C00114A001D00420B2C1A0FF";
break;
default :
_root.victory = 1;
return(undefined);
}
_root.map = new Array(768);
var _local3 = 0;
var _local2 = 0;
var _local7 = "0";
var _local8 = "A";
var _local5 = _local7.charCodeAt(0);
var _local6 = (_local8.charCodeAt(0) - _local5) - 10;
while (true) {
b1 = _local4.charCodeAt(_local3 * 2) - _local5;
b2 = _local4.charCodeAt((_local3 * 2) + 1) - _local5;
_local3++;
if (b1 >= 10) {
b1 = b1 - _local6;
}
if (b2 >= 10) {
b2 = b2 - _local6;
}
if (b2 == 15) {
break;
}
b1++;
while (b1) {
_root.map[_local2] = b2;
b1--;
_local2++;
}
}
_local4 = "";
_root.pos0 = 725;
_root.pos = _root.pos0;
}
_delay = 1;
if (needsInit == undefined) {
init();
}
getinput();
if (_root.victory) {
destroybitmap();
_root.gotoAndPlay("ending");
return(undefined);
}
unchanged = 0;
playgame();
if (!unchanged) {
drawmap();
}
return(undefined);
}
Frame 6
if (!_root.victory) {
gotoAndPlay ("game");
} else {
_root.screen.removeMovieClip();
}
Frame 7
stop();
Frame 10
stop();
Symbol 15 Button
on (release) {
gotoAndPlay (1);
}