User Tools

Site Tools


starting:examples:ponggp

Table of Contents

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

There are 3 main differences between the two sets of code

  1. The stage has been replaced by a single instance consisting of a red line
  2. The costumes for the ball,paddle and redline are drawn by GP itself
  3. The forever loops have been replaced by while loops with waits at the end of the loops
  4. The bouncing off the paddle code has been changed to reflect the difference in directions between Scratch and GP

redline

This script sets the image size and then fills it with red and moves it to bottom of screen

paddle

Creates the paddle image and moves it near bottom of screen


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

Create the ball image by first setting whole image to transparent and then filling a circle in the middle of it


Move the ball to the top of the screen, point it in a random downwards direction and just wait until it touches the redline


Loop moving the ball 4 steps, bouncing off the edges if needed


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)

starting/examples/ponggp.txt · Last modified: 2017/10/02 05:47 by simplesi