Going from Scratch to GP (www.gpblocks.org)
GP is the latest block programming language (Currently in beta testing so changes might/will occur)
It is designed to be a stepping stone (or even an end-goal itself) from Scratch onto more feature rich languages.
This is my attempt to explain some of the key differences between how things work in Scratch and how they work/how to do the same thing in GP.
Please forgive me in advance as I’ll no doubt be mixing up using the correct Computer Science (CS) language and ScratchSpeak 🙂
I’ll try and use colour to indicate differences in naming things e.g ScratchSpeak GPSpeak
It is available for Windows,Mac and Linux from https://gpblocks.org/
There is also a version running on a web server so it can be tried out with any browser also (lacks a few features so better to download and run if possible)
The screen is not as cute and cuddly as Scratch but very similar.
Top left are block categories – next is blocks within category – scripts go bottom left – the stage is on the right.
(GP draws a dotted line to sprites – just click show arrows at top right to switch this off)
Below the stage are the classes and instances – just don’t worry about these names for the moment and treat them as being same as sprites i.e if you want a new sprite – click on Classes +
(Instances + is like Scratch 2 cloning to create a copy of a sprite so just leave that alone for moment)
(If you do press Instances + by mistook, then you can easily get rid of them by pressing Clear button on the right)
There are only 2 inbuilt sprite/class costumes – one called fish and another one called GP.
But you can load any .png type file by clicking on Images tab and selecting Add Images From File.
And your sprite/class you can draw your own costume using the blocks in the Drawing and Pixels categories 🙂
There is a simple example of building a little project here
Lets count to 10 🙂
So main differences were:
When Green Flag click == when I receive go
No say for [ ] seconds block in GP
Now although we can write nearly the exactly same code in GP compared to Scratch, GP has far more programming tools so the the actual way of doing this in GP would be
These for loops are used a lot in most programs (a lot of us thought Scratch should have it as well) as it saves a LOT of work 🙂
The variable i only exists as a temporary variable inside of the loop and is called a loop counter or loop index. You can right-click on it and give it nice name if you want 🙂
Moving a sprite/class around
Major difference to do with movement is direction:
Scratch defines pointing up as direction 0, GP defines pointing right as 0
Scratch defines turning clockwise as an increase in direction, GP defines it as a decrease
My initial gut feeling, is that should be a “use Scratch directions” block for beginners to GP but make it needed at the top of any script block that needs to use it. This way, Scratchers could stick with their world co-ordinate view but makes them work for it – eventually they’d stop using it – consider it like stabilisers on a bicycle 🙂
There is no repeat until block in GP – it has been replaced by while
Consider these two scripts
So in Scratch repeat until will loop the loop until something becomes true but in GP the while will loop the loop while something is true
So in Scratch we are looping until the count is bigger than 10, in GP we loop while the count less than 11
So you have to change count > 10 to shared count < 11 (or shared count <= 10 [ <= means less than or equal to ]
If and If/Else
GP uses one combined if block instead of Scratch’s two types. It can be changed from if to if/else by simply clicking on the black arrow
GPs if/elseif block is much more powerful than the simple example above and can save a lot of nested if statements which leads to your code being easier to read and debug 🙂
Other notable differences
The timer counts up in milliiseconds (thousanths of seconds) and there is no reset timer block. So you have to set a variable, say starttime, to timer value and then subtract the timer from your starttime and divide it by 1000 to get the time difference in seconds
There is no touching colour or touching edge 🙁 You can only detect touching a class or the mouse) There are complex ways around this but much easier/better to just re-think approaches to coding.