Here is a little game entirely speed coded, it’s really not optimised nor commented :crazy:, I just hope you’ll enjoy plaing it
For a 400x400pixels scene over 24fps
Past the code on the first frame :
var scene_w:Number = 400;
var scene_h:Number = 400;
var debugEpais:Number = 1;
var opacite:Number = 100;
var debugOpac:Number = 0;
var arreteImm:String = "0x000000";
var maxSpeed:Array = new Array(5, 7, 9, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50);
var bonux:Array = new Array("health", "damager", "damager", "damager", "enlarge", "slow_down", "speed_up", "speed_up", "speed_up");
var speed:Number = maxSpeed[0];
var Pic:Number = 0;
var decal:Number = 0;
var epaisseur:Number = 50;
var bosses:Number = 30;
var correct:Number = 0;
var s:Number = 0;
var counter:Number = 0;
var tw:Number = 0;
var th:Number = 0;
var maxT:Number = 8;
var bounceLeft:Boolean = false;
var bounceRight:Boolean = false;
var chocks:Number = 0;
var ecart:Number = 1;
var t:Number = 0;
var v:Number = 0;
var bonus_count:Number = 0;
var flashy:Boolean = false;
var isStarted:Boolean = false;
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0x000000;
format.bold = true;
format.size = 12;
var formatN:TextFormat = new TextFormat();
formatN.font = "Verdana";
formatN.color = 0x000000;
formatN.bold = false;
formatN.size = 12;
var formatN2:TextFormat = new TextFormat();
formatN2.font = "Verdana";
formatN2.color = 0x000000;
formatN2.bold = false;
formatN2.size = 9;
var formatG:TextFormat = new TextFormat();
formatG.font = "Verdana";
formatG.color = 0x000000;
formatG.bold = true;
formatG.size = 20;
var formatVert:TextFormat = new TextFormat();
formatVert.font = "Verdana";
formatVert.color = 0x339900;
formatVert.bold = true;
formatVert.size = 14;
var formatRed:TextFormat = new TextFormat();
formatRed.font = "Verdana";
formatRed.color = 0xFF0000;
formatRed.bold = true;
formatRed.size = 14;
var formatBlue:TextFormat = new TextFormat();
formatBlue.font = "Verdana";
formatBlue.color = 0x0000FF;
formatBlue.bold = true;
formatBlue.size = 14;
var formatOr:TextFormat = new TextFormat();
formatOr.font = "Verdana";
formatOr.color = 0xFF9900;
formatOr.bold = true;
formatOr.size = 14;
var formatPurp:TextFormat = new TextFormat();
formatPurp.font = "Verdana";
formatPurp.color = 0xFF00FF;
formatPurp.bold = true;
formatPurp.size = 14;
var score:Number = 0;
var life:Number = 100;
_global.lastLeftPic = 0;
_global.lastLeftPic_two = 0;
_global.lastLeftPic_three = 0;
_global.lastLeftPic_foor = 0;
fscommand.allowscale = true;
Mouse.hide();
this.createTextField("logo", 1011, scene_w-155, 0, 400, 100);
logo.multiline = true;
logo.embedFonts = false;
logo.selectable = false;
logo.text = "AS Corridor by Zappan 2006";
logo.setTextFormat(formatN2);
this.createTextField("explain", 1010, scene_w/2-170, scene_h/2-50, 400, 100);
explain.multiline = true;
explain.embedFonts = false;
explain.selectable = false;
explain.text = "Beware, keep your mouse
in the middle of the screen and...";
explain.setTextFormat(formatN);
this.createTextField("startup", 1004, scene_w/2-170, scene_h/2-20, 400, 100);
startup.multiline = false;
startup.embedFonts = false;
startup.selectable = false;
startup.text = "..::PRESS ENTER TO START::..";
startup.setTextFormat(formatG);
this.createTextField("bonus_shw_extralife", 1005, scene_w/2-100, scene_h/2+20, 300, 100);
bonus_shw_extralife.multiline = true;
bonus_shw_extralife.embedFonts = false;
bonus_shw_extralife.selectable = false;
bonus_shw_extralife.text = "Green balls = Extra life";
bonus_shw_extralife.setTextFormat(formatVert);
this.createTextField("bonus_shw_damage", 1006, scene_w/2-100, scene_h/2+40, 300, 100);
bonus_shw_damage.multiline = true;
bonus_shw_damage.embedFonts = false;
bonus_shw_damage.selectable = false;
bonus_shw_damage.text = "Red balls = Damage 1/2 life";
bonus_shw_damage.setTextFormat(formatRed);
this.createTextField("bonus_shw_enlarge", 1007, scene_w/2-100, scene_h/2+60, 300, 100);
bonus_shw_enlarge.multiline = true;
bonus_shw_enlarge.embedFonts = false;
bonus_shw_enlarge.selectable = false;
bonus_shw_enlarge.text = "Blue balls = Enlarge corridor";
bonus_shw_enlarge.setTextFormat(formatBlue);
this.createTextField("bonus_shw_slow", 1008, scene_w/2-100, scene_h/2+80, 300, 100);
bonus_shw_slow.multiline = true;
bonus_shw_slow.embedFonts = false;
bonus_shw_slow.selectable = false;
bonus_shw_slow.text = "Orange balls = Slow down";
bonus_shw_slow.setTextFormat(formatOr);
this.createTextField("bonus_shw_speed", 1009, scene_w/2-100, scene_h/2+100, 300, 100);
bonus_shw_speed.multiline = true;
bonus_shw_speed.embedFonts = false;
bonus_shw_speed.selectable = false;
bonus_shw_speed.text = "Purple balls = Speed up";
bonus_shw_speed.setTextFormat(formatPurp);
this.createTextField("score_shw", 1000, 10, 10, 100, 100);
score_shw.multiline = false;
score_shw.embedFonts = false;
score_shw.selectable = false;
score_shw.text = "Score :";
score_shw.setTextFormat(format);
this.createTextField("score_txt", 1001, 70, 10, 100, 100);
score_txt.multiline = false;
score_txt.embedFonts = false;
score_txt.selectable = false;
score_txt.variable = "score";
score_txt.setTextFormat(format);
this.createTextField("life_shw", 1002, 10, 30, 100, 100);
life_shw.multiline = false;
life_shw.embedFonts = false;
life_shw.selectable = false;
life_shw.text = "Energy : ";
life_shw.setTextFormat(format);
this.createTextField("life_txt", 1003, 70, 30, 100, 100);
life_txt.multiline = false;
life_txt.embedFonts = false;
life_txt.selectable = false;
life_txt.variable = "life";
life_txt.setTextFormat(format);
this.createEmptyMovieClip("aim", 500);
aim.lineStyle(1, 0x000000, 100, false, "none", "bevel");
aim.moveTo(0, 0);
aim.lineTo(10, 10);
aim.moveTo(10, 0);
aim.lineTo(0, 10);
function make_bonus(mc:Object, type_bonus:String, x:Number, y:Number, r:Number):Void {
mc = this.createEmptyMovieClip(mc, this.getNextHighestDepth());
if (type_bonus == "health") {
color = 0x00FF00;
} else if (type_bonus == "damager") {
color = 0xFF0000;
} else if (type_bonus == "enlarge") {
color = 0x0000FF;
} else if (type_bonus == "slow_down") {
color = 0xFF9900;
} else if (type_bonus == "speed_up") {
color = 0xFF00FF;
} else {
color = 0xFF0000;
mc.typeB = "damager";
}
mc.typeB = type_bonus;
mc.lineStyle(10, color, 50);
mc.beginFill(0x0000FF, 100);
mc.moveTo(x+r, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);
mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);
mc.endFill();
}
this.createEmptyMovieClip("flash_mc", 10000);
flash_mc.beginFill(0xFFFFFF, 100);
flash_mc.moveTo(0, 0);
flash_mc.lineTo(scene_w, 0);
flash_mc.lineTo(scene_w, scene_h);
flash_mc.lineTo(0, scene_h);
flash_mc.endFill();
flash_mc._alpha = 0;
function wall_one() {
if (counter>=5) {
compte();
}
this.createEmptyMovieClip("cd1", 1);
cd1.createEmptyMovieClip("wall_left_mc", 1);
cd1.wall_left_mc.beginFill(0xBBBBBB, opacite);
cd1.wall_left_mc.lineStyle(debugEpais, arreteImm, debugOpac, false, "none", "bevel");
cd1.wall_left_mc.moveTo(0, 0+decal);
cd1.createEmptyMovieClip("wall_right_mc", 2);
cd1.wall_right_mc.beginFill(0xBBBBBB, opacite);
cd1.wall_right_mc.lineStyle(debugEpais, arreteImm, debugOpac, false, "none", "bevel");
cd1.wall_right_mc.moveTo(scene_w, 0+decal);
for (i=0; i<=8; i++) {
Pic = epaisseur+(Math.random()*bosses)-bosses/2;
if (lastLeftPic_two != 0) {
cd1.wall_left_mc.lineTo(lastLeftPic_two, scene_h/8*i+decal);
cd1.wall_right_mc.lineTo(lastLeftPic_foor, scene_h/8*i+decal);
_global.lastLeftPic_two = 0;
} else {
cd1.wall_left_mc.lineTo(Pic, scene_h/8*i+decal);
cd1.wall_right_mc.lineTo(scene_w-cd1.wall_left_mc._width+Pic, scene_h/8*i+decal);
}
_global.lastLeftPic = (decal+scene_h/8*i == scene_h+decal) ? Pic : lastLeftPic;
_global.lastLeftPic_three = (decal+scene_h/8*i == scene_h+decal) ? scene_w-cd1.wall_left_mc._width+Pic : lastLeftPic;
}
cd1.wall_left_mc.lineTo(0, scene_h+decal);
cd1.wall_left_mc.lineTo(0, 0+decal);
cd1.wall_left_mc.endFill();
cd1.wall_right_mc.lineTo(scene_w, scene_h+decal);
cd1.wall_right_mc.lineTo(scene_w, 0+decal);
cd1.wall_right_mc.endFill();
}
function wall_two() {
this.createEmptyMovieClip("cd2", 2);
cd2.createEmptyMovieClip("wall_left_mc", 1);
cd2.wall_left_mc.beginFill(0xBBBBBB, opacite);
cd2.wall_left_mc.lineStyle(debugEpais, arreteImm, debugOpac, false, "none", "bevel");
cd2.wall_left_mc.moveTo(0, scene_h);
cd2.createEmptyMovieClip("wall_right_mc", 2);
cd2.wall_right_mc.beginFill(0xBBBBBB, opacite);
cd2.wall_right_mc.lineStyle(debugEpais, arreteImm, debugOpac, false, "none", "bevel");
cd2.wall_right_mc.moveTo(scene_w, scene_h);
for (i=0; i<=8; i++) {
Pic = (scene_h+scene_h/8*i == scene_h) ? lastLeftPic : epaisseur+(Math.random()*bosses)-bosses-2;
lastLeftPic_three = (scene_h+scene_h/8*i == scene_h) ? lastLeftPic_three : scene_w-cd2.wall_left_mc._width+Pic;
cd2.wall_left_mc.lineTo(Pic, scene_h+scene_h/8*i);
cd2.wall_right_mc.lineTo(lastLeftPic_three, scene_h+scene_h/8*i);
_global.lastLeftPic_two = (scene_h+scene_h/8*i == scene_h*2) ? Pic : lastLeftPic_two;
_global.lastLeftPic_foor = lastLeftPic_three;
}
cd2.wall_left_mc.lineTo(0, scene_h*2);
cd2.wall_left_mc.lineTo(0, scene_h);
cd2.wall_left_mc.endFill();
cd2.wall_right_mc.lineTo(scene_w, scene_h*2);
cd2.wall_right_mc.lineTo(scene_w, scene_h);
cd2.wall_right_mc.endFill();
}
onEnterFrame = function () {
if (Key.isDown(Key.ENTER)) {
if (life>0) {
isStarted = true;
startup.text = "";
explain._visible = false;
bonus_shw_speed._visible = false;
bonus_shw_damage._visible = false;
bonus_shw_extralife._visible = false;
bonus_shw_enlarge._visible = false;
bonus_shw_slow._visible = false;
} else {
isStarted = true;
startup.text = "";
life = 100;
epaisseur = 50;
bosses = 30;
score = 0;
s = 0;
counter = 0;
speed = maxSpeed[0];
explain._visible = false;
bonus_shw_speed._visible = false;
bonus_shw_damage._visible = false;
bonus_shw_extralife._visible = false;
bonus_shw_enlarge._visible = false;
bonus_shw_slow._visible = false;
}
}
if (life == 0) {
startup._x = scene_w/2-180;
startup.text = "..::PRESS ENTER TO RESTART::..";
startup.setTextFormat(formatG);
explain._visible = true;
bonus_shw_speed._visible = true;
bonus_shw_damage._visible = true;
bonus_shw_extralife._visible = true;
bonus_shw_enlarge._visible = true;
bonus_shw_slow._visible = true;
}
if (isStarted) {
if (speed>5) {
if (cd1._y<cd2._y) {
cd2._y = cd1._y+cd1._height-1;
} else {
cd1._y = cd2._y+cd2._height-1;
}
}
if (aim.hitTest(tracker._x-tracker._width, tracker._y-tracker._height, false) || aim.hitTest(tracker._x+tracker._width, tracker._y+tracker._height, false)) {
if (bounceLeft || bounceRight) {
bounceLeft = bounceRight=false;
}
}
life = (life<0) ? 0 : life;
life_txt.setTextFormat(format);
if (cd1.hitTest(tracker._x, tracker._y, true) || cd2.hitTest(tracker._x, tracker._y, true)) {
if (!Key.isDown(Key.END)) {
life -= (life>0) ? 1*score/100 : life;
life = (life>0) ? Math.floor(life*100)/100 : life;
life_txt.setTextFormat(format);
}
if (tracker._x<scene_w/2) {
tracker._x += 30;
bounceRight = false;
bounceLeft = true;
} else {
tracker._x -= 30;
bounceRight = true;
bounceLeft = false;
}
}
if (tracker._x<0) {
bounceLeft = true;
bounceRight = false;
} else if (tracker._x>scene_w) {
bounceRight = true;
bounceLeft = false;
}
if (bounceRight) {
bounceLeft = false;
tracker._x -= 20;
tracker._y += 5;
}
if (bounceLeft) {
bounceRight = false;
tracker._x += 30;
tracker._y += 5;
}
if (tracker._y>=scene_h) {
bounceLeft = bounceRight=false;
}
epaisseur += (epaisseur<=180) ? 0.1 : 0;
bosses += (bosses<=150) ? 0.1 : 0;
if (!cd1) {
wall_one();
if (!cd2) {
wall_two();
}
} else {
cd1._y -= speed;
if (cd2) {
cd2._y -= speed;
}
}
if (cd1._y<=-scene_h-decal) {
decal = scene_h;
wall_one();
}
if (cd2._y<=-scene_h-decal) {
wall_two();
}
}
};
function compte() {
if (life>0) {
speed = maxSpeed[s];
s += (s<maxSpeed.length-1) ? 1 : 0;
}
}
this.createEmptyMovieClip("tracker", 3);
tracker.beginFill(0xCC6600, 100);
tracker.lineStyle(2, 0xCC6600);
drawCircle(tracker, 0, 0, 10);
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
mc.moveTo(0+x, 0+y);
mc.lineTo(10+x, 10+y);
mc.moveTo(10+x, 0+y);
mc.lineTo(0+x, 10+y);
}
tracker._x = scene_w/2;
tracker.endFill();
for (i=0; i<maxT; i++) {
mc = tracker.duplicateMovieClip("tracker"+i, 100+i);
mc.mass = i/0.5;
mc._alpha = (100-(i*100/maxT)+1)/2;
}
setInterval(function () {
if (isStarted) {
score += (life>0) ? 0.01*speed : 0;
score = (Math.floor(score*100))/100;
score_txt.setTextFormat(format);
ecart = (Math.abs(tracker._xmouse+tracker._ymouse)/5>2) ? Math.abs(tracker._xmouse+tracker._ymouse)/5 : 1;
if (!bounceLeft && !bounceRight && life>0) {
tracker._x += tracker._xmouse/ecart-_x;
tracker._y += tracker._ymouse/ecart-_y;
_root["tracker"+t]._x += (_root["tracker"+t]._xmouse-_x)/_root["tracker"+t].mass*6.5;
_root["tracker"+t]._y += (_root["tracker"+t]._ymouse-_y)/_root["tracker"+t].mass*6.5;
} else {
_root["tracker"+t]._x = tracker._x-_x/_root["tracker"+t].mass*6.5;
_root["tracker"+t]._y = tracker._y-_y/_root["tracker"+t].mass*6.5;
}
if (life == 0) {
_root["tracker"+t]._visible = false;
speed -= (speed>0) ? 0.1 : 0;
speed = (speed<0) ? 0 : speed;
if (cd1._y<cd2._y) {
cd2._y = cd1._y+cd1._height-1;
} else {
cd1._y = cd2._y+cd2._height-1;
}
} else {
_root["tracker"+t]._visible = true;
tracker0._visible = false;
}
t += (t<maxT) ? 1 : -t;
}
aim._x = _xmouse;
aim._y = _ymouse;
if (flashy) {
trace(flashy);
flash_mc._alpha += (flash_mc._alpha<100) ? 10 : 0;
} else {
flash_mc._alpha -= (flash_mc._alpha>0) ? 20 : 0;
}
if (flash_mc._alpha>=90) {
flashy = false;
}
}, 5);
_global.moveIt = function() {
this._y -= speed;
if (this._y<0) {
this.unloadMovie();
}
if (cd1.hitTest(this._x, this._y, true) || cd2.hitTest(this._x, this._y, true)) {
if (this._x<scene_w/2) {
this._x += 40;
} else {
this._x -= 40;
}
}
if (tracker.hitTest(this._x, this._y, false)) {
flashy = true;
if (this.typeB == "health") {
life += 100;
life = (life>0) ? Math.floor(life*100)/100 : life;
life_txt.setTextFormat(format);
} else if (this.typeB == "damager") {
life = (life>0) ? life/2 : life;
life = (life>0) ? Math.floor(life*100)/100 : life;
life_txt.setTextFormat(format);
} else if (this.typeB == "enlarge") {
epaisseur = (epaisseur/2>25) ? epaisseur/2 : 50;
bosses = (bosses/2>15) ? bosses/2 : 30;
} else if (this.typeB == "slow_down") {
s = (s-1>0) ? s-1 : 0;
speed = maxSpeed[s];
} else if (this.typeB == "speed_up") {
s += (s<maxSpeed.length-1) ? 1 : 0;
speed = maxSpeed[s];
}
this.unloadMovie();
}
};
setInterval(function () {
if (isStarted && life>0) {
if (bonus_count%2 == 0) {
typeX = bonux[Math.round(Math.random()*(bonux.length-1))];
typeX = (speed<7 && typeX == "speed_up") ? "damager" : typeX;
make_bonus("bon"+bonus_count, typeX, 0, 0, 5);
_root["bon"+bonus_count]._x = Math.random()*scene_w;
_root["bon"+bonus_count]._y = scene_h+6;
_root["bon"+bonus_count].onEnterFrame = moveIt;
}
counter += (counter<=maxT) ? 1 : -counter;
bonus_count++;
}
}, 1000);