PDA

View Full Version : Dodge the Boxes



jerez_z
January 23rd, 2006, 09:33 PM
Here it is. My masterpiece.

Dodge the Boxes (25 lines):

hitsLeft = _root.createTextField("hitsLeft", 3, 10, 368, 400, 22);
_root.stuff = {alive:true, age:0, score:0, hits:0, gameOver:[[196, 144], [196, 136], [188, 136], [180, 136], [172, 136], [164, 136], [164, 144], [164, 152], [164, 160], [164, 168], [164, 176], [172, 176], [180, 176], [188, 176], [196, 176], [196, 168], [196, 160], [188, 160], [212, 176], [216, 168], [220, 160], [224, 152], [228, 144], [232, 136], [236, 144], [240, 152], [244, 160], [248, 168], [256, 176], [228, 160], [236, 160], [268, 176], [272, 168], [276, 160], [280, 152], [284, 144], [288, 136], [292, 144], [296, 152], [300, 160], [304, 168], [308, 176], [312, 168], [316, 160], [320, 152], [324, 144], [328, 136], [332, 144], [336, 152], [340, 160], [344, 168], [348, 176], [364, 136], [372, 136], [380, 136], [388, 136], [396, 136], [364, 144], [364, 152], [372, 156], [380, 156], [388, 156], [364, 160], [364, 168], [364, 176], [372, 176], [380, 176], [388, 176], [396, 176], [188, 192], [196, 192], [204, 192], [212, 192], [220, 192], [188, 200], [220, 200], [188, 208], [220, 208], [188, 216], [220, 216], [188, 224], [220, 224], [188, 232], [196, 232], [204, 232], [212, 232], [220, 232], [236, 192], [240, 200], [244, 208], [248, 216], [252, 224], [256, 232], [260, 224], [264, 216], [268, 208], [272, 200], [276, 192], [292, 192], [300, 192], [308, 192], [316, 192], [324, 192], [292, 200], [292, 208], [300, 212], [308, 212], [316, 212], [292, 216], [292, 224], [292, 232], [300, 232], [308, 232], [316, 232], [324, 232], [340, 192], [348, 192], [356, 192], [364, 192], [372, 192], [340, 200], [372, 200], [340, 208], [372, 208], [340, 216], [348, 216], [356, 216], [364, 216], [372, 216], [340, 224], [368, 224], [340, 232], [372, 232]]};
(_root.createEmptyMovieClip("holder", 1)).attachBitmap((all=new flash.display.BitmapData(550, 400, true)), 1);
drawBox((box=holder.createEmptyMovieClip("box", 2)));
onEnterFrame = function () {
if (Math.random()*100>Math.max(40, 100-((_root.stuff.age++)/15)) && _root.stuff.alive) {
drawBox((temp=holder.box.duplicateMovieClip("box"+holder.getNextHighestDepth(), holder.getNextHighestDepth(), {_x:550, _y:Math.random()*380, speed:Math.random()*5+5, _alpha:Math.random()*70+30})), true);
temp.onEnterFrame = function() {
(this.hitTest(_root.holder.box)) ? explode(this) : null;
(this._x<-20 && _root.stuff.alive) ? _root.stuff.score++ : null;
(this._x<-20) ? this.removeMovieClip() : this._x -= this.speed;
};
}
holder.box._y += (Math.max(0, Math.min(400, _root._ymouse-10))-box._y)/10;
holder.box._x += (Math.max(0, Math.min(550, _root._xmouse-10))-box._x)/10;
all.draw(new flash.display.BitmapData(550, 400, true, 0x44FFFFFF));
all.draw(holder);
hitsLeft.text = "Score: "+_root.stuff.score+" Hits Remaining: "+((_root.stuff.hits == undefined) ? 0 : (17-_root.stuff.hits));
};
function explode(clip) {
for (var i = 0; i<25; i++) {
drawBox((particle=holder.box.duplicateMovieClip("particle"+_root.holder.getNextHighestDepth(), _root.holder.getNextHighestDepth(), {_x:clip._x, _y:clip._y, vx:Math.random()*20-5, vy:-(Math.random()*10+10), _xscale:20, _yscale:20})), true);
particle.onEnterFrame = function() {
(this._x>550 || this._x<0) ? this.removeMovieClip() : this._x += this.vx;
(this._y>400) ? this.removeMovieClip() : this._y += (this.vy += 3);
};
}
((_root.stuff.hits++)>15) ? die((_root.stuff.alive=false)) : clip.removeMovieClip();
}
function die(bool) {
for (var i = 0; i<_root.stuff.gameOver.length; i++) {
drawBox((particle=holder.box.duplicateMovieClip("particle"+_root.holder.getNextHighestDepth(), _root.holder.getNextHighestDepth(), {_x:clip._x, _y:clip._y, vx:Math.random()*20-5, vy:-(Math.random()*10+10), _xscale:20, _yscale:20, tx:_root.stuff.gameOver[i][0], ty:_root.stuff.gameOver[i][1]})), false);
particle.onEnterFrame = function() {
this._x += ((this.tx-this._x)/15)+Math.max(0, this.vx -= .3);
this._y += ((this.ty-this._y)/15)+Math.max(0, this.vy -= .3);
};
}
holder.box.removeMovieClip();
}
function drawBox(clip, rand) {
clip.attachBitmap(new flash.display.BitmapData(20, 20, false, ((rand) ? Math.random()*0xFFFFFF : 0x000000)), 1);
}


EDIT: Added score counter
EDIT 2: Fixed score display problem
EDIT 3: My best score is 1616 (before I got bored)

freeskier89
January 23rd, 2006, 09:41 PM
Really, really nice! I love the game over piece! :D

kdd
January 23rd, 2006, 10:30 PM
omg... it's cool...
edit: uses a lot of cpu sometimes...

jerez_z
January 23rd, 2006, 10:33 PM
ya I'm trying to think of ways to lower it.......

scags
January 23rd, 2006, 11:08 PM
Yeah, lol you almost killed my crappy laptop :P

I'll look at it again when I can be on a computer that doesn't make horrible clicking noises and freeze up and explode when I run it :lol:

hybrid101
January 24th, 2006, 12:23 AM
lags on my computer...it looks very cool though! nice trail effect!:pac:

jerez_z
January 24th, 2006, 12:25 AM
anybody have any ideas on how to reduce lag?

NiñoScript
January 24th, 2006, 01:42 AM
looks really cool, i like that Game Over efect too :D


anybody have any ideas on how to reduce lag?
maybe u can reduce the number of trailing boxes :)

nobody
January 24th, 2006, 01:56 AM
Holy crap you crashed my browser! Definitely knocks off a trailing box or two, I think it'l help a ton. Awesome game though!

bwh2
January 24th, 2006, 02:43 AM
would be awesome if it weren't so cpu hungry.

Gelatine Cow
January 24th, 2006, 07:55 AM
Awesome! I too love the 'GAME OVER' part.:thumb::thumb:

Deril
January 24th, 2006, 08:44 AM
wow..!
impresive!

jerez_z
January 24th, 2006, 10:56 AM
the trailing boxes are all done with the bitmap object.

squan
January 24th, 2006, 11:19 AM
instead of the hit counter you should write a little score counter ... that way we can compare scores. That would top it off.

Gelatine Cow
January 24th, 2006, 11:41 AM
Yeah, what he said ^ ;)

Pattt
January 24th, 2006, 12:06 PM
Really nice! :)

jerez_z
January 24th, 2006, 02:27 PM
ok guys V4 is up. (Note: works much better when viewed at 100% and not in the browser.. if I could free up one more line I could add "noScale")

EDIT: Fixed the score display problems, now scale isn't that big a problem.

Seb Hughes
January 25th, 2006, 04:01 PM
That owns.

NiñoScript
January 25th, 2006, 07:44 PM
2279 pts :D

calvintage
January 25th, 2006, 09:09 PM
i got 285... this is amazing.

jerez_z
January 25th, 2006, 09:14 PM
yes! I might be able to compete with the particle clock

freeskier89
January 25th, 2006, 10:56 PM
Yes! 3011 pts and still going strong :D and I can type this reply while I am playing!

Just resize your brower window and bring the box to the very bottom. I feel smart... or I just thought outside of the box lol.

5366 now!

jerez_z
January 25th, 2006, 10:59 PM
holy.... get a life :crazy:

freeskier89
January 25th, 2006, 11:04 PM
:lol: At least I wasn't able to manually sit through 1616 pts like you! Just kidding. :beam: Very nice entry by the way again

Seb Hughes
January 26th, 2006, 06:33 AM
When i played i had to many boxes flying at me.

jerez_z
January 26th, 2006, 09:23 AM
thats the point

Seb Hughes
January 26th, 2006, 02:00 PM
Yep but like there was no possible way i could dodge them jeremy.

GNXDan
February 3rd, 2006, 01:51 PM
500 pnts !

notsocoolxp
August 6th, 2007, 09:24 PM
Awsome. :D