danielvann
Gebruiker
- Lid geworden
- 26 jun 2008
- Berichten
- 23
ey ik ben net begonnen met flash
wat moet ik doen met deze code als ik hem in een site wil plaatsen
stop();
xspeed = 0;
yspeed = 0;
friction = 0.8;
turntest = 0;
shotcount = 0;
shottime = 10;
motionspeed = 1;
xmoved = 0;
mlcounter = 0;
misslecount = 0;
xdist = new Array(20, 250, 260, 550, 560, 570, 850, 860, 870, 880, 1250, 1260, 1270, 1280, 1290, 1550, 1560);
xplace = new Array(100, 410, 110, 380, 220, 125, 260, 300, 110, 350, 155, 300, 205, 65, 370, 105, 210);
_root.attachMovie("back1", "back1", _root.getNextHighestDepth(), {_x:250, _y:0});
_root.attachMovie("back2", "back2", _root.getNextHighestDepth(), {_x:250, _y:-400});
_root.createEmptyMovieClip("shotmovie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("enemies", _root.getNextHighestDepth());
_root.createEmptyMovieClip("bonusmovie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("missles", _root.getNextHighestDepth());
_root.attachMovie("ship", "ship", _root.getNextHighestDepth(), {_x:250, _y:400});
ship.onEnterFrame = function() {
_root.shipmover();
if (xmoved>1600) {
xmoved = 0;
}
_root.shooter();
_root.mover();
_root.renderer();
_root.hitenemy();
};
function shipmover() {
ship._x += xspeed;
ship._y += yspeed;
if (ship._x<10) {
ship._x = 10;
}
if (ship._x>490) {
ship._x = 490;
}
if (ship._y<40) {
ship._y = 40;
}
if (ship._y>390) {
ship._y = 390;
}
xspeed = xspeed*friction;
yspeed = yspeed*friction;
if (Key.isDown(Key.UP)) {
yspeed--;
}
if (Key.isDown(Key.DOWN)) {
yspeed++;
}
if (Key.isDown(Key.LEFT)) {
turntest++;
xspeed--;
}
if (Key.isDown(Key.RIGHT)) {
turntest--;
xspeed++;
}
if (turntest != 0) {
ship._width = 35;
} else {
ship._width = 40;
}
turntest = 0;
}
function mover() {
back1._y += motionspeed;
back2._y += motionspeed;
if (back1._y>=400) {
back1._y = -400;
}
if (back2._y>=400) {
back2._y = -400;
}
xmoved++;
}
function shooter() {
shottime--;
if (shottime == 0) {
if (shotcount == 7) {
shotcount = 0;
}
shottime = 10;
shot = shotmovie.attachMovie("shot", "shot"+shotcount, shotmovie.getNextHighestDepth(), {_x:ship._x, _y:ship._y-14});
shotcount++;
shot.speed = 8;
shot.onEnterFrame = function() {
this._y -= this.speed;
if (this._y<0) {
this.removeMovieClip();
}
};
}
}
function renderer() {
for (i=0; i<17; i++) {
if (xmoved == xdist) {
enemy = enemies.attachMovie("mlauncher", "mlauncher"+mlcounter, enemies.getNextHighestDepth(), {_x:xplace, _y:0});
enemy.health = 5;
enemy.shottime = 20;
enemy.onEnterFrame = function() {
myRadians = Math.atan2(ship._y-this._y, ship._x-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(ship._y-this._y);
_root.xChange = Math.round(ship._x-this._x);
this._rotation = myDegrees+90;
this.shottime--;
if (this.shottime == 0) {
this.shottime = 40;
missle = missles.attachMovie("missle", "missle"+misslecount, missles.getNextHighestDepth(), {_x:this._x, _y:this._y});
misslecount++;
if (misslecount>15) {
misslecount = 0;
}
if (ship._x>=this._x) {
missle.xspeed = (5*(this._x-ship._x)*(this._x-ship._x))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
} else {
missle.xspeed = 0-(5*(this._x-ship._x)*(this._x-ship._x))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
}
if (ship._y>=this._y) {
missle.yspeed = (5*(this._y-ship._y)*(this._y-ship._y))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
} else {
missle.yspeed = 0-(5*(this._y-ship._y)*(this._y-ship._y))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
}
missle.onEnterFrame = function() {
this._x += this.xspeed;
this._y += this.yspeed;
if (this.hitTest(ship)) {
ship.gotoAndPlay(2);
this.removeMovieClip();
}
if (this._x<0 or this._x>500 or this._y<0 or this._y>400) {
this.removeMovieClip();
}
};
}
this._y += motionspeed;
if (this._y>400) {
this.removeMovieClip();
}
};
mlcounter++;
}
}
if (mlcounter == 9) {
mlcounter = 0;
}
}
function hitenemy() {
for (i=0; i<9; i++) {
for (j=0; j<7; j++) {
if (shotmovie["shot"+j].hitTest(enemies["mlauncher"+i])) {
shotmovie["shot"+j].removeMovieClip();
enemies["mlauncher"+i].health--;
if (enemies["mlauncher"+i].health>0) {
enemies["mlauncher"+i].gotoAndPlay(2);
} else {
for (k=0; k<Math.random()*8; k++) {
star = bonusmovie.attachMovie("bonus", "bonus"+bonusmovie.getNextHighestDepth(), bonusmovie.getNextHighestDepth(), {_x
(enemies["mlauncher"+i]._x+Math.random()*20)-10), _y
(enemies["mlauncher"+i]._y+Math.random()*20)-10)});
star.xspeed = (Math.random())-0.5;
star.yspeed = motionspeed;
star.onEnterFrame = function() {
this._x += this.xspeed;
this._y += this.yspeed;
if (this.hitTest(ship)) {
this.removeMovieClip();
}
};
}
enemies["mlauncher"+i].removeMovieClip();
}
}
}
}
}
wat moet ik doen met deze code als ik hem in een site wil plaatsen
stop();
xspeed = 0;
yspeed = 0;
friction = 0.8;
turntest = 0;
shotcount = 0;
shottime = 10;
motionspeed = 1;
xmoved = 0;
mlcounter = 0;
misslecount = 0;
xdist = new Array(20, 250, 260, 550, 560, 570, 850, 860, 870, 880, 1250, 1260, 1270, 1280, 1290, 1550, 1560);
xplace = new Array(100, 410, 110, 380, 220, 125, 260, 300, 110, 350, 155, 300, 205, 65, 370, 105, 210);
_root.attachMovie("back1", "back1", _root.getNextHighestDepth(), {_x:250, _y:0});
_root.attachMovie("back2", "back2", _root.getNextHighestDepth(), {_x:250, _y:-400});
_root.createEmptyMovieClip("shotmovie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("enemies", _root.getNextHighestDepth());
_root.createEmptyMovieClip("bonusmovie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("missles", _root.getNextHighestDepth());
_root.attachMovie("ship", "ship", _root.getNextHighestDepth(), {_x:250, _y:400});
ship.onEnterFrame = function() {
_root.shipmover();
if (xmoved>1600) {
xmoved = 0;
}
_root.shooter();
_root.mover();
_root.renderer();
_root.hitenemy();
};
function shipmover() {
ship._x += xspeed;
ship._y += yspeed;
if (ship._x<10) {
ship._x = 10;
}
if (ship._x>490) {
ship._x = 490;
}
if (ship._y<40) {
ship._y = 40;
}
if (ship._y>390) {
ship._y = 390;
}
xspeed = xspeed*friction;
yspeed = yspeed*friction;
if (Key.isDown(Key.UP)) {
yspeed--;
}
if (Key.isDown(Key.DOWN)) {
yspeed++;
}
if (Key.isDown(Key.LEFT)) {
turntest++;
xspeed--;
}
if (Key.isDown(Key.RIGHT)) {
turntest--;
xspeed++;
}
if (turntest != 0) {
ship._width = 35;
} else {
ship._width = 40;
}
turntest = 0;
}
function mover() {
back1._y += motionspeed;
back2._y += motionspeed;
if (back1._y>=400) {
back1._y = -400;
}
if (back2._y>=400) {
back2._y = -400;
}
xmoved++;
}
function shooter() {
shottime--;
if (shottime == 0) {
if (shotcount == 7) {
shotcount = 0;
}
shottime = 10;
shot = shotmovie.attachMovie("shot", "shot"+shotcount, shotmovie.getNextHighestDepth(), {_x:ship._x, _y:ship._y-14});
shotcount++;
shot.speed = 8;
shot.onEnterFrame = function() {
this._y -= this.speed;
if (this._y<0) {
this.removeMovieClip();
}
};
}
}
function renderer() {
for (i=0; i<17; i++) {
if (xmoved == xdist) {
enemy = enemies.attachMovie("mlauncher", "mlauncher"+mlcounter, enemies.getNextHighestDepth(), {_x:xplace, _y:0});
enemy.health = 5;
enemy.shottime = 20;
enemy.onEnterFrame = function() {
myRadians = Math.atan2(ship._y-this._y, ship._x-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(ship._y-this._y);
_root.xChange = Math.round(ship._x-this._x);
this._rotation = myDegrees+90;
this.shottime--;
if (this.shottime == 0) {
this.shottime = 40;
missle = missles.attachMovie("missle", "missle"+misslecount, missles.getNextHighestDepth(), {_x:this._x, _y:this._y});
misslecount++;
if (misslecount>15) {
misslecount = 0;
}
if (ship._x>=this._x) {
missle.xspeed = (5*(this._x-ship._x)*(this._x-ship._x))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
} else {
missle.xspeed = 0-(5*(this._x-ship._x)*(this._x-ship._x))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
}
if (ship._y>=this._y) {
missle.yspeed = (5*(this._y-ship._y)*(this._y-ship._y))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
} else {
missle.yspeed = 0-(5*(this._y-ship._y)*(this._y-ship._y))/(((this._x-ship._x)*(this._x-ship._x))+((this._y-ship._y)*(this._y-ship._y)));
}
missle.onEnterFrame = function() {
this._x += this.xspeed;
this._y += this.yspeed;
if (this.hitTest(ship)) {
ship.gotoAndPlay(2);
this.removeMovieClip();
}
if (this._x<0 or this._x>500 or this._y<0 or this._y>400) {
this.removeMovieClip();
}
};
}
this._y += motionspeed;
if (this._y>400) {
this.removeMovieClip();
}
};
mlcounter++;
}
}
if (mlcounter == 9) {
mlcounter = 0;
}
}
function hitenemy() {
for (i=0; i<9; i++) {
for (j=0; j<7; j++) {
if (shotmovie["shot"+j].hitTest(enemies["mlauncher"+i])) {
shotmovie["shot"+j].removeMovieClip();
enemies["mlauncher"+i].health--;
if (enemies["mlauncher"+i].health>0) {
enemies["mlauncher"+i].gotoAndPlay(2);
} else {
for (k=0; k<Math.random()*8; k++) {
star = bonusmovie.attachMovie("bonus", "bonus"+bonusmovie.getNextHighestDepth(), bonusmovie.getNextHighestDepth(), {_x


star.xspeed = (Math.random())-0.5;
star.yspeed = motionspeed;
star.onEnterFrame = function() {
this._x += this.xspeed;
this._y += this.yspeed;
if (this.hitTest(ship)) {
this.removeMovieClip();
}
};
}
enemies["mlauncher"+i].removeMovieClip();
}
}
}
}
}
Laatst bewerkt: