johnish
06-19-2008, 02:07 AM
hey guys, i know this is a noob mistake.... but i have no ieda
i made a pong game and it obviously records a score..
the code below is on the ball
//This section is only processed once.
onClipEvent (load) {
var xspeed = 12;
var yspeed = 12;
score1 = 0;
score2 = 0;
}
//This section is processed every frame
onClipEvent (enterFrame) {
if (this._x>600) {
_root.score2 ++;
}
if (this._x<0) {
_root.score1 ++;
}
//Check if the pong block has gone below the stage area
if ((this._y+this._height)>Stage.height) {
//set the pong block to the bottom edge of the stage
this._y = Stage.height-this._height;
//set the pong block to move up
yspeed *= (-1);
}
//Check if the pong block has gone above the stage area
if (this._y<0) {
//set the pong block to the top edge of the stage
this._y = 0;
//set the pong block to move down
yspeed *= (-1);
}
//Check if the pong block has gone to the left or right of the stage area
if ((this._x+this._width<0) || (this._x>Stage.width)) {
//left side scored
if (this._x>Stage.width) {
_root.leftscore++;
}
//right side scored
if (this._x+this._width<0) {
_root.rightscore++;
}
//set the pong block to the middle of the stage
this._x = Stage.width/2;
//set the pong block to move in the opposite direction horizontally
xspeed *= (-1);
}
//move the x and y positions of the pong block
_x += xspeed;
_y += yspeed;
}
and that doesnt work. when it scores it displays NaN
ive also tried +=1
that just adds one.. ie score 1 then 11 then 111 so forth...
please help me out
i made a pong game and it obviously records a score..
the code below is on the ball
//This section is only processed once.
onClipEvent (load) {
var xspeed = 12;
var yspeed = 12;
score1 = 0;
score2 = 0;
}
//This section is processed every frame
onClipEvent (enterFrame) {
if (this._x>600) {
_root.score2 ++;
}
if (this._x<0) {
_root.score1 ++;
}
//Check if the pong block has gone below the stage area
if ((this._y+this._height)>Stage.height) {
//set the pong block to the bottom edge of the stage
this._y = Stage.height-this._height;
//set the pong block to move up
yspeed *= (-1);
}
//Check if the pong block has gone above the stage area
if (this._y<0) {
//set the pong block to the top edge of the stage
this._y = 0;
//set the pong block to move down
yspeed *= (-1);
}
//Check if the pong block has gone to the left or right of the stage area
if ((this._x+this._width<0) || (this._x>Stage.width)) {
//left side scored
if (this._x>Stage.width) {
_root.leftscore++;
}
//right side scored
if (this._x+this._width<0) {
_root.rightscore++;
}
//set the pong block to the middle of the stage
this._x = Stage.width/2;
//set the pong block to move in the opposite direction horizontally
xspeed *= (-1);
}
//move the x and y positions of the pong block
_x += xspeed;
_y += yspeed;
}
and that doesnt work. when it scores it displays NaN
ive also tried +=1
that just adds one.. ie score 1 then 11 then 111 so forth...
please help me out