Google Classroom
GeoGebraGeoGebra Klaslokaal

Play the game of PONG

Learn how to program the simple and classic game of PONG. The whole game is based on 4 points : the ball (A), the playing field (B, C) and the the playing pad (D) of length 2L
This is the script associated with the button Start SetValue[in, false] SetValue[out, false] SetValue[score, 0] SetValue[speed, 0.2] SetValue[dx, 1] SetValue[dy, 1] SetValue[A, round((B+C)/2)] StartAnimation[] This is the script associated with the slider time SetValue[A, A+v*speed] If[x(A)<=x(B), SetValue[dx, abs(dx)]] If[x(A)>=x(C), SetValue[dx, -abs(dx)]] If[y(A)>=y(C), SetValue[dy, -abs(dy)]] If[y(A)<=y(B), If[x(A)>=x(D)-L && x(A)<=x(D)+L, SetValue[in, true],SetValue[out, true]]] If[in, SetValue[dy, abs(dy)]] If[in, SetValue[score, score+1]] If[in, SetValue[speed, speed+0.1]] If[out, StartAnimation[false]] SetValue[in, false]