PDA

View Full Version : Click and hold to move...



kookaburra
January 13th, 2006, 05:30 AM
This seems complete now.
Please feel free to comment.



c = 0;
//1
flag = 1;
//2
createTextField("score", 11, 440, 75, 100, 25);
//3
createTextField("inst", 12, 100, 75, 250, 25);
//4
inst.text = "Click and hold to move up. Leave to move down";
//5
function drawRect(NAME, x, y, w, h, col, depth) {
var rect:MovieClip = _root.createEmptyMovieClip(NAME, depth);
//6
rect._x = x;
//7
rect._y = y;
//8
rect.beginFill(col, 80);
//9
rect.lineTo(w, 0);
//10
rect.lineTo(w, h);
//11
rect.lineTo(0, h);
//12
}
drawRect("upper", 100, 100, 400, 20, 0x000000, 1);
//13
drawRect("lower", 100, 300, 400, 20, 0x000000, 9);
//14
drawRect("player", 125, 150, 25, 25, random(16777215), 8);
//15
drawRect("obstacle", 500, 120+random(120), 20, 60, 0xFF0000, 7);
//16
onEnterFrame = function () {
player._y = player._y<125 ? 125 : player._y>270 ? 270 : player._y+flag*6;
//17
obstacle._x<100 ? drawRect("obstacle", 500, 120+random(120), 20, 60, 0xFF0000, 7) : obstacle._x -= 5;
//18
player.hitTest(obstacle) ? loadMovie("AD_Kirupa_25_Contest_13012004.swf", _root) : score.text="Score: "+(c++);
//19
player.onMouseDown = function() {
flag = -1;
//20
};
player.onMouseUp = function() {
flag = 1;
//21
};
};

icio
January 13th, 2006, 07:01 AM
Reminds me of that helicopter game in the arcade (which I love).
Nice work

hybrid101
January 13th, 2006, 10:15 AM
try adding hittesting to the upper and lower walls if it were possible to actually compress the code. nice one!

NiñoScript
January 13th, 2006, 10:57 AM
good game :)
i like it :D


but, just a question...

player.hitTest(obstacle) ? loadMovie("AD_Kirupa_25_Contest_13012004.swf", _root) : score.text="Score: "+(c++);

what are you trying to load? it doesnt load anything here :puzzle:
and its in the rules that you cant load external things.

freeskier89
January 13th, 2006, 08:08 PM
I think he is just trying to reset the game. Kind of a clever way to reset the variables :D Try using getURL instead.

senocular
January 13th, 2006, 08:20 PM
loadMovieNum(_url, 0) usually does the trick too

kdd
January 13th, 2006, 09:15 PM
though this has a huge bug. if you just don't click and keep that square bouncing at the bottom, your score will go up, but the game won't close... :(

kookaburra
January 14th, 2006, 06:57 AM
though this has a huge bug. if you just don't click and keep that square bouncing at the bottom, your score will go up, but the game won't close... :(
You're mistaken..
The obstacle comes at random so it can always come the bottom also..

kookaburra
January 14th, 2006, 07:02 AM
loadMovieNum(_url, 0) usually does the trick too
awesome..

Seb Hughes
January 14th, 2006, 09:47 AM
Nifty :D