drawPanel = function () { p.lineStyle(1, 0x000000, 100); p.moveTo(400, 0); p.beginFill(0xFF0000, 100); p.lineTo(Stage.width, 0); p.lineTo(Stage.width, Stage.height); p.lineTo(400, Stage.height); p.lineTo(400, 0); p.endFill(); }; TFO = function() { t.lineStyle(1, 0x000000, 100); t.moveTo(420, 20); t.beginFill(0xFFFFFF, 100); t.lineTo(530, 20); t.lineTo(530, 33); t.lineTo(420, 33); t.lineTo(420, 20); t.endFill(); } drawBgd = function () { bgd.lineStyle(1, 0x000000, 100); bgd.moveTo(0, 0); bgd.beginFill(0x333333, 100); bgd.lineTo(400, 0); bgd.lineTo(400, Stage.height); bgd.lineTo(0, Stage.height); bgd.lineTo(0, 0); bgd.endFill(); }; boxcolor = function (red) { a.clear(); a.lineStyle(1, 0x000000, 100); a.moveTo(0, 0); if (red) { a.beginFill(0xFF0000, 100); } else { a.beginFill(0x0000FF, 100); } a.lineTo(sS >> 1, 0); a.lineTo(sS >> 1, -sS); a.lineTo(-(sS >> 1), -sS); a.lineTo(-(sS >> 1), 0); a.lineTo(0, 0); a.endFill(); }; makeNewPlatform = function () { pHolder.createEmptyMovieClip("p"+d, d); pHolder["p"+d].lineStyle(1, 0x000000, 100); pHolder["p"+d].moveTo(0, 0); pHolder["p"+d].beginFill(0x00FF00, 100); pHolder["p"+d].lineTo(100, 0); pHolder["p"+d].lineTo(100, 20); pHolder["p"+d].lineTo(0, 20); pHolder["p"+d].lineTo(0, 0); pHolder["p"+d].endFill(); pHolder["p"+d]._x = 100*(random(4)); pHolder["p"+d]._y = Stage.height; pHolder["p"+d].hit = hitTest; d++; }; startGameBox = function () { s.lineStyle(1, 0x000000, 100); s.moveTo(50, 150); s.beginFill(0x0000FF, 100); s.lineTo(350, 150); s.lineTo(350, 350); s.lineTo(50, 350); s.lineTo(50, 150); s.endFill(); }; makeButton = function () { b.lineStyle(1, 0x000000, 100); b.moveTo(70, 290); b.beginFill(0xFFFFFF, 100); b.lineTo(330, 290); b.lineTo(330, 330); b.lineTo(70, 330); b.lineTo(70, 290); b.endFill(); }; startGame = function () { _root.createEmptyMovieClip("pHolder", d++); b.clear(); s.clear(); bG.text = bG2.text=bG3.text=""; playing = true; }; drawSpikes = function () { k.lineStyle(1, 0x000000, 100); for (i=0; i<20; i++) { k.moveTo(i*20, 0); k.beginFill(0x999999, 100); k.lineTo((i+1)*20, 0); k.lineTo(((i+1)*20)-10, 30); k.lineTo(i*20, 0); k.endFill(); } }; playing = false; d = 0; _root.createEmptyMovieClip("bgd", d++); _root.createEmptyMovieClip("k", 99999999999999); _root.createEmptyMovieClip("p", d++); _root.createEmptyMovieClip("a", d++); _root.createEmptyMovieClip("s", d++); _root.createEmptyMovieClip("b", d++); _root.createEmptyMovieClip("t", d++); _root.createTextField("texteh", d++, 420, 20, 110, 13); _root.createTextField("copyright", d++, 441, Stage.height-37, 146, 17); _root.createTextField("copyright2", d++, 410, Stage.height-24, 146, 17); _root.createTextField("bG", d++, 70, 170, 260, 26); _root.createTextField("bG2", d++, 70, 183, 260, 26); _root.createTextField("bG3", d++, 156, 304, 260, 26); a.falling = true; bG.selectable = bG2.selectable=texteh.selectable=bG3.selectable=copyright.selectable=copyright2.selectable=free=free2=false; bG.text = "Use the left and right arrow keys to fall from platform"; bG2.text = " to platform, and stay alive for as long as possible!"; bG3.text = "Click here to play!"; copyright.text = "Copyright (c)"; copyright2.text = "Gamesgamesgames.co.uk"; sS = 20; a.hit = hit=hitTest; a.fallSpeed = a._y=0; speed = 5; a._x = 200; c = c2=14; pDeaddy = d; drawPanel(); drawBgd(); startGameBox(); makeButton(); drawSpikes(); texteh.autoSize = "left"; b.onRelease = function() { startGame(); TFO(); }; clearStage = function () { a.clear(); t.clear(); playing = free=free2=false; removeMovieClip(pHolder); a._x = 200; pDeaddy = a.fallSpeed=a._y=0; d = 15; drawPanel(); makeButton(); startGameBox(); bG.bold = true; bG.text = " Awww... too bad. You lost. Your final score was: "; bG2.bold = true; bG2.textAlign = "center"; bG2.text = " "+score; bG3.text = " Play again? "; texteh.text = ""; score = 0; }; _root.onEnterFrame = function() { if (playing) { free = a._y>50 ? true : false; ++score; --c; collisions = 0; if (Key.isDown(Key.LEFT)) { a._x = a._x>0+(a._width >> 1) ? a._x-speed : a._x; } else if (Key.isDown(Key.RIGHT)) { a._x = a._x<400-(a._width >> 1) ? a._x-(-speed) : a._x; } if (a.falling) { boxcolor(false); a.fallSpeed = a.fallSpeed<15 ? a.fallSpeed-(-1) : 14; a._y -= -a.fallSpeed; } else { boxcolor(true); a.fallSpeed = 0; } if (c<=0) { makeNewPlatform(); c = c2; } for (i=pDeaddy; i<=d; i++) { if (pHolder["p"+i]._y<-20) { removeMovieClip(pHolder["p"+i]); ++pDeaddy; } if (pHolder["p"+i].hit(a._x, a._y, true)) { ++collisions; a._y = (pHolder["p"+i]._y-5); } pHolder["p"+i]._y -= speed; } a.falling = collisions>0 ? false : true; texteh.text = score; if (free) { free2 = true; delete (free); } if (free2) { if (a.hit(k) || a._y>Stage.height+40) { clearStage(); } } } };