Crippy
1
ok, i have a pong game and have got the bats working but i need the ball 2 do 2 things
a) i need the ball to just bounce around the screen randomly, and make a speedthing on it cause i cant get 1 to work
b) i need the hittest on the ball so it hits the paddles and bounces off them
im not sure if anyone needs this information but i have the inctance names, bat1 and bat2. and thats about it.
system
2
Off the top of my head (Put this in the ball):
onClipEvent(load){
speedX = 10;
speedY = 10;
counter = 10;//Or whatever. You’ll see what this is for
stageWidth = //The stage width
stageHeight = //The stage height
}
onClipEvent(enterFrame){
if(counter <= 0){
counter = 10;
speedX = random(//some number)+1;
speedY = random(//some number)+1;
}
counter --;
this._x += speedX;
this._y += speedY;
if((this._x > stageWidth-(_width/2)) or (this._x < _width/2) or (this._y < _height/2) or (this._y > stageHeight - (_height/2)) or (this.hitTest(_root.bat1)) or (this.hitTest(_root.bat2))){
speedX = -speedX;
speedY = -speedY;
}
}
That MAY work. Like I said, I just made that up off the top of my head