# Pong (Horray...)

**URL:** <https://forum.kirupa.com/t/pong-horray/247006>\
**Category:** programming\
**Created:** [December 17, 2007, 5:45pm UTC](https://forum.kirupa.com/t/pong-horray/247006 "2007-12-17T17:45:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Theo\_wk](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Theo\_wk](https://forum.kirupa.com/u/Theo_wk)\
**Post date:** [December 17, 2007, 5:45pm UTC](https://forum.kirupa.com/t/pong-horray/247006/1 "2007-12-17T17:45:15Z")

</div>

I’ve got a basic version of pong up and running, but I can’t figure out how to reset the ball back to it’s original speed every time a point is scored, also i can’t seem to increase the computer opponent lag to make the game possible to win. Anyhelp would be greatly appreciated.

> 

Mouse.hide();  
bounce = 1  
vx = Math.random()\*5+2;  
vy = Math.random()\*5+2;  
top = 0;  
bottom = 300;  
left = 0;  
right = 500;  
playerscore = 0;  
computerscore = 0;  
ball.onEnterFrame = ballMove;  
playerpaddle.onEnterFrame = playerMove;  
computerpaddle.onEnterFrame = computerMove;  
function ballMove() {  
this.\_x += vx;  
this.\_y += vy;  
if (this.\_y\<top) {  
this.\_y = top;  
vy \*= -bounce;  
}  
if (this.\_y\>bottom) {  
this.\_y = bottom;  
vy \*= -bounce;  
}  
if (this.\_x\<left) {  
this.\_x = left;  
vx \*= -bounce;  
}  
if (this.\_x\>right) {  
this.\_x = right;  
vx \*= -bounce;  
}  
if (this.hitTest(playerpaddle)) {  
vx \*= -bounce;  
vy \*= -bounce;  
}  
if (this.hitTest(computerpaddle)) {  
vx \*= -bounce;  
vy \*= -bounce;  
}  
if (this.\_x\<=5) {  
this.\_x = 250;  
this.\_y = 150;  
playerscore++;  
}  
if (this.\_x\>=495) {  
this.\_x = 250;  
this.\_y = 150;  
computerscore++;  
}  
}  
function playerMove() {  
this.\_y = \_ymouse;  
}  
function computerMove() {  
this.\_y = ball.\_y;  
}
