-
PONG expression
I got this script from further down the forum.
I am trying to make a script that is like pong. Where the ball bounces between the four sides of a box, forever. I can add the paddles after, to make it look like someone is playing the game.I got this expression off creativecow.net but it doesn’t bounce between the sides
box=[10,10,100,200]; // box you want to stay in [x1,y1,x2,y2]
motion=[312,123]; // motion-vector in pixels per sond [x,y]
startpos=[160,120]; // startposition// calculations:
w=box[2]-box[0]; h=box[3]-box[1]; corner=[box[0],box[1]];
delta=motion*time; pos=startpos+delta-corner;
xx=pos[0]%(w*2); yy=pos[1]%(h*2);corner+[xx,yy]
Anyone got a script that would bounce an between the four sides of the screen forever?
Thanks