(Not too sure which forum this belongs in but i think this should be right)
Okay, i’ve made a simple pong game, it has a score system and i think it’s pretty simple and good.
But i’ve got a very strange problem with it.
The game has Preloader, intro, menu and then the actual game. I tested the game out by clicking the “Test Scene” option, and the pong game worked perfect, like i wanted it to.However, i chose the “Test Movie” option and when i get to the game, it doesn’t work. I am able to move the paddle up and down, but neither the ball or the opponent’s paddle moves.
I’m not sure what information you will need. But for the game to work, there is one script written and put on the first frame of the game. This is the script.
Please help, i’ve been around so many different places to find help and nobody knows!
_root.onLoad = function() {
ymov = 4;
xmov = 4;
stop();
enemyx = 2;
enemyy = 2;
_root.playerscore = 0;
_root.enemyscore = 0;
};
_root.onEnterFrame = function() {
_root.block._x += xmov;
_root.block._y += ymov;
// Tells the ball where to go when you get hit
if (_root.block.hitTest(_root.wall)) {
xmov *= -1;
ymov *= 1;
}
if (Key.isDown(Key.DOWN)) {
_root.wall._y += 5;
} else if (Key.isDown(Key.UP)) {
_root.wall._y -= 5;
}
if (_root.block.hitTest(_root.bottom)) {
xmov *= 1;
ymov *= -1;
}
if (_root.block.hitTest(_root.top)) {
xmov *= 1;
ymov *= -1;
}
if (_root.block.hitTest(_root.left)) {
xmov *= -1;
ymov *= 1;
}
if (_root.block._y>_root.left._y) {
_root.left._y += enemyy;
}
if (_root.block._y<_root.left._y) {
_root.left._y -= enemyy;
}
// Boundries for top and bottom
if (_root.wall.hitTest(_root.bottom)) {
_root.wall._y -= 5;
}
if (_root.wall.hitTest(_root.top)) {
_root.wall._y += 5;
}
if (_root.left.hitTest(_root.bottom)) {
_root.left._y -= 4;
}
if (_root.left.hitTest(_root.top)) {
_root.left._y += 4;
}
if (_root.block.hitTest(_root.score1)) {
_root.enemyscore = _root.enemyscore+1;
_root.block._x = 249.7;
_root.block._y = 187.7;
_root.block._x -= xmov;
}
if (_root.block.hitTest(_root.score2)) {
_root.playerscore = _root.playerscore+1;
_root.block._x = 249.7;
_root.block._y = 187.7;
_root.block._x += xmov;
}
if (_root.enemyscore == 10) {
_root.gotoAndStop("Lose");
}
if (_root.playerscore == 10) {
_root.gotoAndStop("Win");
}
};