fez
December 2nd, 2002, 09:38 PM
just so you all know, i didnt actually write this code. so im not really as smart as i may seem...getting back to the point, what im looking for is a semi thorough explanation for the following lines. excluding this
and this
and this
init();
function init() {
right = 500;
left = 50;
top = 50;
bottom = 350;
ball.vx = Math.random()*20-10;
ball.vy = Math.random()*20-10;
ball.onEnterFrame = move;
pc.onEnterFrame = function() {
this._y = ball._y;
};
player.onEnterFrame = function() {
this._y = _root._ymouse;
};
Mouse.hide();
}
function move() {
this._x += this.vx;
this._y += this.vy;
playerBounds = player.getBounds(_root);
if (this._x>right-this._width/2) {
if (this._y>playerBounds.yMin && this._y<playerBounds.yMax) {
this.vx *= -1;
this._x = right-this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
pcScore++;
}
}
pcBounds = pc.getBounds(_root);
if (this._x<left+this._width/2) {
if (this._y>pcBounds.yMin && this._y<pcBounds.yMax) {
this.vx *= -1;
this._x = left+this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
playerScore++;
}
}
if (this._y>bottom-this._height/2) {
this.vy *= -1;
this._y = bottom-this._height/2;
}
if (this._y<top+this._height/2) {
this.vy *= -1;
this._y = top+this._height/2;
}
}
cheers
fez
ps. its a pong sort of game btw
and this
and this
init();
function init() {
right = 500;
left = 50;
top = 50;
bottom = 350;
ball.vx = Math.random()*20-10;
ball.vy = Math.random()*20-10;
ball.onEnterFrame = move;
pc.onEnterFrame = function() {
this._y = ball._y;
};
player.onEnterFrame = function() {
this._y = _root._ymouse;
};
Mouse.hide();
}
function move() {
this._x += this.vx;
this._y += this.vy;
playerBounds = player.getBounds(_root);
if (this._x>right-this._width/2) {
if (this._y>playerBounds.yMin && this._y<playerBounds.yMax) {
this.vx *= -1;
this._x = right-this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
pcScore++;
}
}
pcBounds = pc.getBounds(_root);
if (this._x<left+this._width/2) {
if (this._y>pcBounds.yMin && this._y<pcBounds.yMax) {
this.vx *= -1;
this._x = left+this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
playerScore++;
}
}
if (this._y>bottom-this._height/2) {
this.vy *= -1;
this._y = bottom-this._height/2;
}
if (this._y<top+this._height/2) {
this.vy *= -1;
this._y = top+this._height/2;
}
}
cheers
fez
ps. its a pong sort of game btw