Today, once again there are two options.
The first is a little Scratch game I have created based on Frogger.
This is a really simple game, but it shows some of the basics you might need to know to make a game in Scratch.
First you need to create a background – using a colour for the “water” or “road” in the middle, and a different colour for the safe areas at the top and bottom. To do this, click on the “stage” icon and then choose to edit the background in the middle window.
Your next job is to create a “log”. I just painted a brown rectangle in the built-in editor, but you could use one of the Sprites that comes with Scratch, or make something different. The six “logs” will need a script each, something like this:
This will place the log at the edge of the screen and keep moving it across until it reaches the other size. At that point it is put back at the beginning. I’ll leave it up to you to work out how to get a block to start in the middle and keep looping around.
The “frog” will need a script like this:
This should look simple enough. If you get stuck, let me know and I will give you a bit of help.
If you prefer to work on Python, you can return to the program we we’re looking at last week, if you wish. Alternatively, I have been working on a little program that works out the Caesar Ciphers we were looking two weeks ago in class.
It’s a gui program and the output looks like this:
I’m not going to give you all the code this time. You can download part of it here: code.py.
I have given you the code to set up the GUI – you’ll see something like this if you run it. What I have taken out is the function “submit()” which takes the input from the text box and encodes or decodes it.
I’d like you to have a go at writing this function. If you get stuck, you can ask me for a bit of help.
You’ll probably want to make a list or string with the letters of the alphabet. You can then use a method like “string.find(‘a’)” or “list.index(‘b’)” to give you the position of a certain letter in the string (or list). You can then add or subtract from this number to find the position of the new letter you’ll need.