At 6/23/05 05:25 PM, Ninja-Chicken wrote:
Well yeah API has a few uses but nothing good.
I made a full game in API.
onLoad = function () {
time = 0;
rand1 = random(250)+25;
_root.createEmptyMovieClip("wall1", 10);
with (wall1) {
lineStyle(5, 0x000000, 100);
moveTo(0, 200);
lineTo(rand1, 200);
}
_root.createEmptyMovieClip("wall2", 11);
with (wall2) {
lineStyle(5, 0x000000, 100);
moveTo(rand1, 250);
lineTo(550, 250);
}
_root.createEmptyMovieClip("wall3", 12);
with (wall3) {
lineStyle(5, 0x000000, 100);
moveTo(rand1, 200);
lineTo(rand1, 250);
}
_root.createEmptyMovieClip("char1", 50);
with (char1) {
lineStyle(2, 0xFFFFFF, 100);
moveTo(_x-15, _y-15);
beginFill(0xFFFFFF, 50);
lineTo(_x+15, _y-15);
lineTo(_x+15, _y+15);
lineTo(_x-15, _y+15);
lineTo(_x-15, _y-15);
endFill();
}
_root.createEmptyMovieClip("char2", 49);
with (char2) {
lineStyle(2, 0xFFFFFF, 50);
moveTo(_x-15, _y-15);
beginFill(0xFFFFFF, 30);
lineTo(_x+15, _y-15);
lineTo(_x+15, _y+15);
lineTo(_x-15, _y+15);
lineTo(_x-15, _y-15);
endFill();
}
_root.createEmptyMovieClip("coin1", 100);
with (coin1) {
lineStyle(2, 0xFFFF00, 100);
beginFill(0xFFCC00, 100);
lineTo(_x+10, _y);
lineTo(_x+10, _y+10);
lineTo(_x, _y+10);
lineTo(_x, _y);
endFill();
}
_root.createEmptyMovieClip("base", 0);
with (base) {
lineStyle(1, 0x000000, 0);
moveTo(0, 200);
beginFill(0x00CC66, 100);
lineTo(rand1, 200);
lineTo(rand1, 250);
lineTo(550, 250);
lineTo(550, 400);
lineTo(0, 400);
lineTo(0, 200);
endFill();
}
score = 0;
score.txt = 0;
coin1._x = random(400)+50;
coin1._y = random(180);
};
onEnterFrame = function () {
myRadians = Math.atan2(char1._y-char2._y, char2._y-char2._x);
_root.yChange = Math.round(char1._y-char2._y);
_root.xChange = Math.round(char1._x-char2._x);
_root.yMove = Math.round(_root.yChange/1.5);
_root.xMove = Math.round(_root.xChange/1.5);
char2._y += _root.yMove;
char2._x += _root.xMove;
time += 1;
if (time == 600) {
time = 0;
score -= 10;
}
if (0>score) {
char1.removeMovieClip();
char2.removeMovieClip();
_root.createEmptyMovieClip("lose1", 100000);
with (lose1) {
lineStyle(3, 0x000000, 100);
lineTo(0, 50);
lineTo(5, 50);
moveTo(10, 50);
lineTo(10, 0);
lineTo(30, 0);
lineTo(30, 50);
lineTo(10, 50);
moveTo(55, 0);
lineTo(35, 0);
lineTo(35, 25);
lineTo(55, 25);
lineTo(55, 50);
lineTo(35, 50);
moveTo(80, 0);
lineTo(60, 0);
lineTo(60, 50);
lineTo(80, 50);
moveTo(60, 25);
lineTo(80, 25);
}
}
if (char1.hitTest(wall1) || char1.hitTest(wall2)) {
} else {
char1._y += 3;
}
if (Key.isDown(Key.LEFT)) {
if (char1.hitTest(wall3)) {
} else {
char1._x -= 5;
}
}
if (Key.isDown(Key.RIGHT)) {
char1._x += 5;
}
if (Key.isDown(Key.UP)) {
char1._y -= 5;
}
if (char1.hitTest(coin1)) {
coin1._x = random(400)+50;
coin1._y = random(180);
bell1 = new Sound();
bell1.attachSound("ding1");
bell1.start(0, 1);
bell1.setVolume(random(200)+50);
score += 1;
}
if (Key.isDown(Key.SPACE)) {
trace("Your score is "+score);
}
};
I'll make a AS: API topic now.