Start a new Scratch project - "File" and then "New"
There are some terms that you need to know.
- The text that is being encrypted is called "plain text".
- The encrypted version of the plain text is called "cypher text"
- The number of places left or right that the alphabet moves is called the "offset". The person who receives the cypher text must uise the same offset to decrypt it. In effect the offset is the key.
The next step is to get Scratch to ask for a phrase from the user.use the ask block from "sensing" to do this. Change the default text "What is your name?" to be "What is the plain text?". Scratch will store whatever the user types in as a system variable called "answer".
The next step used a counting variable. You will use this technique quite frequently.
The problem is we are to repeat a process once for every letter in the phrase that the user wants to encrypt. So would could use the repeat block, but this needs to know how many times we are to repeat the task and we don't know how many, so we use a variable.
Traditionally the letter i is used. If another variable is required to do a similar job them we would use the letter j and then k if necessary.
So make a variable called i and write the code to set the value of i to be 1.
We are going to repeat the next process once for every letter in the phrase that the user enters. There is a block to tell us the number of characters (or length) in a phrase (or string) that Scratch has stored in the system variable called "answer". There is a block called "length of", drag this in and then drag the variable "answer" to replace the word "World".
Add a repeat block to the code and drop the length of on to the number of times the loop is to be repeated.
Now we need to inspect the phrase (or string which is the proper name for a set of text) so we use "letter of". Drag the "letter of" block and drag the system variable "answer" to replace "World". Then drag the variable i from the variables to replace the number 1 so that instead of "letter 1 of world" the block says "letter i of answer". The variable i starts at 1 and finishes when it has gone through every letter of the phrase (or string).
Make a new list called "plain_text" to store each letter of the phrase currently stored in the system variable answer, one letter at a time.
Next drag the "add thing to plain_text" block and drop "letter i of answer" over "thing".
Finally increase i by 1 by using the change i by 1 block.
Save and run the code so far. Scratch should ask you for a phrase so type in something simple such as "plain" and press the enter key. You will see your phrase (or string) appear as a set of letters in the list "plain_text".
Run the code again and what do you notice?
Each new phrase is added to plain_text rather than replace it. We solve this in the next section.
Frequently when progrrammers write code they find that the effect of the code that they wrote earlier still exists in the computer. When you input a string (phrase or set of letters) in to a list (or array as some programmers call it) you have to empty the list if you want to use it again.
So, drag the "delete 1 of plain_text" to the start of the thread and change 1 to be all. This will now delete the contents of the nlist "plain_text" when the thread starts so that it is empty when the user is asked for a string (phrase or sel of letters).
2. Screenshot your project so far and describe how you created the laser.
Add another sprite and give it the alien costume. The aliens have a strange but predictable motion, they will march to the right and when the first one gets to the edge of the screen they all come down a little and then march to the left and when the first one gets to the left edge of the screen, march down a bit and then march to the right and then repeat till they get to the bottom of the screen. To make life more interesting there are groups of them.
The thread that you write must check that the right most alien is near the edge of the screen and then make all of the aliens simultaneously march down a short space and then march to the left. This is done with a broadcast instruction.
Now duplicate the alien and change the "go to" block x values to be -200, -150, -100. -50, 0 and 50 for the 6 aliens.
When you press the space bar they should all move together.
When you shoot an alien with the laser the alien vanishes (or hides).3. Screenshot your project so far and describe how you created the first set of aliens.
Add another row of aliens by duplicating each of the existing aliens and change the y value from 120 to 80
Now add two threads to each alien, one to detect being struck by a missile and then hide or vanish and then another to collide with the ship and say "Game over".
Check to see that this works correctly4. Screenshot your project so far and describe how you created the first set of aliens.
Create a row of 4 barriers to protect the ship using the "barrier" costume from the "Invaders" folder. If the aliens hit the barriers the game is over and the ship cannot fire through the barriers at the aliens.
You can duplicate the barrier and change the x value of the "go to" block.to be -150, -50, 50 and 150. This will space the barriers out neatly.
Add the largest asteroid from the folder and give it the motion as shown in hte image. The idea of the game is that when the asteroid passes out of view it will continue its journey in the same direction from the opposite side of the screen4. Screenshot your project so far and describe how you added At least one of the improvements given above.
Add the other smaller asteroids as costumes to the larger asteroid.
This is the working game although there are a few little issues to clear up. First, when the missile hits an asteroid it continues still hitting the asteroid so one shot is usually enough. Change this so that the asteroids has to be hit by different missiles to be destroyed. Second, in the real game when the asteroid is struck it splits in to two so there will be two middle sizes asteroids and then each if these will divide into two. Thirdly the asteroids get faster as they get smaller.4. Screenshot your project so far and describe how you added At least one of the improvements given above.
The arcade game also had an interesting way of moving the spaceship. As there is no gravity it behaves like a free body, i.e. if there is no acceleration then it continues in the same direction at the same velocity. It has the same limitation as an asteroid in that if it goes off the screen then it reappears on the opposite side.5. Screenshot your project so far and describe how you added all of the improvements given above in both extensions