====== PongGP ====== This is a copy of the original Scratch Pong game, re-written in GP to show some of the differences and similarities between Scratch and GP {{:starting:examples:ponggp:screen1.png|}} There are 3 main differences between the two sets of code - The stage has been replaced by a single instance consisting of a red line - The costumes for the ball,paddle and redline are drawn by GP itself - The forever loops have been replaced by while loops with waits at the end of the loops - The bouncing off the paddle code has been changed to reflect the difference in directions between Scratch and GP ===== redline ===== {{:starting:examples:ponggp:redline.png |}} This script sets the image size and then fills it with red and moves it to bottom of screen ===== paddle ===== {{:starting:examples:ponggp:paddle1.png |}} Creates the paddle image and moves it near bottom of screen ---- {{:starting:examples:ponggp:paddle2.png |}}Make the paddle track the mouseX position in the equivalent of a forever loop. Notice the need for a wait (for screen refresh) at the end of the loop ===== ball ===== {{:starting:examples:ponggp:ball1.png |}}Create the ball image by first setting whole image to transparent and then filling a circle in the middle of it ---- {{:starting:examples:ponggp:ball2.png |}}Move the ball to the top of the screen, point it in a random downwards direction and just wait until it touches the redline ---- {{:starting:examples:ponggp:ball3.png |}}Loop moving the ball 4 steps, bouncing off the edges if needed ---- {{:starting:examples:ponggp:ball4.png |}}The main script in the program.\\ Loop and if the the ball touches the paddle, change its direction to bounce off it (and add a bit of randomness to it)