Operators in any programming language are used when you want to calculate something new: they operate on values. variables, or expressions to produce a new value.
As we have seen before, in ScriptCraft you use a drone to do your building for you. The drone has functions that are part of it.
Here are some of the main drone functions that are useful when building your mods:
You can find lots more about these and other functions in the ScriptCraft API Reference: https://github.com/walterhiggins/ScriptCraft/blob/master/docs/API-Reference.md
Example: Build a Pyramid
This example is based on a very nice program writing by Ruaidhri from Coderdojo Athenry last year, updated slightly because some ScriptCraft commands have changed in the meantime.
// Copyright Ruaidhri from ModderDojo Athenry,
// slightly updated by Michael and Alex.
// Builds a pyramid with entrance and lights inside.
exports.pyramid = function()
echo('making a pyramid');
var d = new Drone(self); // 'self' means start drone beside me
// Make the walls
while (size > 0)
// Lights inside
var t = 0;
t = t + 1;
Last Saturday, we had a fantastic time creating very simple stop motion videos in scratch by taking pictures of small figurines in sequence and then uploading the pictures from cameras and phones to the computer. We then started Scratch and added the very first picture as a SPRITE from a file. All the subsequent pictures were then added as new costumes to this sprite!
We did have to do a very simple code for the sprite – when the GREEN FLAG is pressed the sprite FOREVER uses the NEXT COSTUME command and WAITS .1 seconds. The computer then moves from the first costume down to the last, very quickly, but not so quickly that we can’t see it happen! The result looks like we have taken a video. Check out the scratch.mit.edu website for the demo that I used – Julie Animation. Search the site for cdathenry1516 games.
Next week, we will take a look at Paint.net,which is a drawing program. I will quickly go through the menus but the best way to learn a program like this is to use it and experiment with it. We will use it to try to delete the backdrop from some of our pictures that were taken last week to see if we can make it transparent. When we do, we will be able to see our own backdrops in behind our characters.
Please download the Paint.net program from www.getpaint.net/download.html. Please be careful of ADS. Only download from the recommended site. I will bring a copy on a belt.
Next week, the Moms and Dads should bring along a camera or phone along with the lead to download the pictures to your laptop.
***Next week we will be doing Animation! Please bring any miniature figures that you might want to use to create a short story through stop motion photography. We will also need some way to take photos and download the images to the computer – so parents need to remember a camera and download cables. I will bring a big load of modelling clay.***
Breakout is a variation of our previous game, Paddleball. We create a new scoring experience for our gamers by introducing blocks at the top of our screen that they get points for hitting.
Everyone already knew how to import or create the first two sprites – the paddle and the ball and most coders remembered from paddleball how to get the paddle to forever follow the mouse in only the x-direction.
The code to move the ball was essentially the same as in the paddle ball game with a small change to broadcast the starting position to itself.
We then created two variables, one for the score which will go up when the ball hits a block sprite(can you copy this code from the Paddleball game code and use it in the ball sprite?) and one for lives which will go down every time the ball touches the end line we added under the paddle on the Backdrop. Can you figure out where to put the code to reduce lives by one when the ball touches a certain colour?
Lastly, we created the block sprites and coded for them to fade away when they touched the ball. We use the EFFECT block of code in LOOKS.
The complete set of notes in .PDF format can be opened here:CDA-S5-Challenge_08_Breakout. You can play with my completed game on the http://scratch.mit.edu webpage. If you sign in as cdathenry1516 and use the password: cdathenry, you will be able to play all our games. If you have your own sign in name, just search for cdathenry1516 and you can see and play them all as well. Please put yours up there as well!
See you all next week!
Since we had a terrific guest speaker today, there wasn’t enough time to rework our paddle ball game to the famous breakout game, so I picked out the quick (but really neat) drawing game! The .pdf of the slides can be found here:CDA-S5-Challenge_08-Pen Command-.
In order to make it easier to change the values that control the angles of the drawing and the length of the sides, we created variables that we could change via sliders on the STAGE (right click on the variable on the stage after you create it and a menu pops up giving you some options, including a slider option). Replace the handwritten numbers in the TURN and the MOVE motion commands with the variables for speed and degrees. When you touch the green flag and start the movement of your sprite, you can slide the sliders to get the perfect (or craziest) drawing! Duplicate your sprite and get several sprites drawing at once.
One extra bit that we didn’t get to is to use buttons to start and stop our drawing. Create two new button sprites and script them to send a broadcast when clicked.
Just edit the script in the drawing sprite by putting the WHEN I RECEIVE event command at the top of the drawing script and select the START broadcast. Add another bit to the drawing sprite to STOP ALL when it receives the STOP broadcast from the Stop button.
Next week we will do the breakout game and we will plan the animation project for the following week.
Don’t forget to upload your projects to the website: scratch.mit.edu! Put it on your own login and share it or put it on ours: cdathenry1516.
All the best,
This we will create our first app. The app will make it easy for you to open your favourite web sites.
Getting Started designing the GUI
Drag and Drop a “HorizontalArrangement” component on to the designer screen
- Rename the “HorizontalArrangement” to “hsaButtons”
- Set the “Width” property of the “HorizontalArrangement” to “Fill parent”
Drag and Drop three “Button” components into the “HorizontalArrangement”
- Rename the three “Button” components to “btnGoogle”, “btnYouTube” and “btnCoderDojo”
- Change the “Text” property for each of the three Button components to “Google”, “YouTube” and “CoderDojo”
- Set the “Width” property of each “Button” to “Fill parent”
Drag and Drop a “WebViewer” component on to the designer screen
- Rename the “WebViewer” component to “wbvBrowser”
Getting Started writing the code
- Click on the “Blocks” button
- In the script designer click on the “Button” Block “btnGoogle”
- Select the “when btnGoogle.Click” script from the pop-out list
- In the script designer click on the “WebViewer” Block “wbvBrowser”
- Select the “call wbvBrowser.GoToLink” script from the pop-out list
- In the script designer click on the “Text” Block, select the emptry String Block
- Copy and Paste the url http://www.google.ie into the “Text” block
Test the app
Duplicate the script above for the other two buttons.
App Inventor Notes Week 4 – FavouriteBrowser
Note: some individual topics are short: we got most of the way through the first 3 in our taster session. See this post: https://cdathenry.wordpress.com/2015/09/27/minecraft-modding-taster-session-week-1/
Steps 1-3: Install ScriptCraft, Learn how to Connect to a Server, and Create a First Mod
We covered these steps in the first two weeks:
- How to Connect to Each Other’s Servers
- Creating our First ScriptCraft Mods
To try out ScriptCraft, look back at the introductory posts here: https://cdathenry.wordpress.com/2015/09/27/minecraft-modding-taster-session-week-1/
Some people criticise Scratch as being “childish”, but I don’t agree. While it is designed so that even 8 year olds can use it, it is still has all of the key features of ‘adult’ programming languages, as listed in the image at the top of this post.
(Technically, any programming language with variables, decision and loops is Turing Complete.)
We had another week of fantastic attendance at Coder Dojo Athenry Beginners Scratch session. Thanks all for coming. To see the PDF of this weeks notes click here: CDA-S5-Challenge_05_Paddle_Ball. This week we reiterated a lot of the basic programming ideas that we have been working on since September. We planned our game – Paddle Ball – by defining it’s rules and designing it’s look. The coders were invited to use whatever sprites they liked-some had dragons catching swords and others trampolines catching kids! Most stuck to the basic layout seen here:
First, we designed the paddle and made it follow our mouse, but only in the x-direction.
Secondly, we drew or imported the ball from our library and caused it to fall. We had to set it’s initial position just after the green flag was pressed in order that the game would restart properly each time and we had to set it’s initial direction to down, otherwise the ball might just bounce from side to side instead of up and down!! In order to do this, we placed a ‘point in direction’ block under the ‘go to’ block in the image below and set it to 180 (or down).
Now that we have each sprite moving, we must get them to respond to touching each other and get a score variable set up. When the ball hits the paddle, the ball will broadcast a message to the program and the ball will change the score by 1.
To end our program I decided that when the ball hit a line I drew at the bottom of the STAGE. The command of ‘wait until’ was used with ‘touching colour’ to ‘stop all’. The coders were encouraged to continue the game instead by setting up a ‘lives’ variable and merely subtracting from that variable when the ball touches the line and ending the game when ‘lives = 0’.
Next week we will quickly re-make the basic paddle ball game but add a twist to it by making blocks that disappear when hit and add to the user’s score. It is based on the old Breakout game. The following week we will be doing animation. I will be bringing some plasticine to use to make sprites but the coders are welcome to bring miniature figurines such as Polly pockets or lego, etc… All parents should come equipped with a phone/camera and download cables that can take pictures to record the action! This will take several weeks to complete.
Thanks to Martha Fahy for the fantastic game idea and notes!
This week we improved on Martha’s original Ghost Catcher game! The notes can be found on this website as CDA-S5-Challenge_04-BetterGhostCatcher.
We animated our ghosts by creating a simple change costume script that runs forever,
We made our ghosts broadcast a message when they are caught to make ghostcatcher (aka Bob) change his costume (Hint!: First, we made a new costume for Ghostcatcher Bob to make his mouth look closed!),
We also got Ghostcatcher Bob to broadcast a message that makes the stage change it’s background to each time a level is changed.
If you have any questions about all the variables, ghostscaught and speed, that you saw in my version of the program, please review the notes on this website for the previous week: CDA-S5-Week_03-Ghostcatcher.pdf. Check out the last few slides.
Thanks to Martha Fahy for all her notes so that we could really make huge progress with our Ghost Catcher game!
Have a very Happy Halloween and we will see ye all back on Saturday November 7th at 12.00!
Great to see so many of you there on Saturday. This weeks starting point was our game from last week. We wanted to add extra functionality. We added code to the Heart so that something happened when the Hippo touched it. Most people added some sound.
We also made our first variable. We did this so that we could keep track of our score. Using this score we also could add code to make something happen when you reached a certain score and win the game. Again here we added a sound and switched backgrounds.
We learned and used a lot of new code this week and we will see over the coming weeks how we can incorporate it into many different types of games.
Why don’t you try using all the code we have used so far to create your own game. We will take time at the beginning of next weeks session to look at any games that people want to show us.
See you all next week!
Here are the notes from todays session in PDF CDA-S5-Week_02-FirstGame-Part2.pdf
This season at CoderDojo Athenry, the advanced groups are all starting with taster sessions of the various topics we will cover.
Here are the notes:
- How to Connect to Each Other’s Servers
- Creating our First ScriptCraft Mods
Coming up next week: in introduction to Raspberry Pi and Electronics