AppInventor Week 4: Favourite Browser

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

  1. Click on the “Blocks” button
  2. In the script designer click on the “Button” Block “btnGoogle”
  3. Select the “when btnGoogle.Click” script from the pop-out list
  4. In the script designer click on the “WebViewer” Block “wbvBrowser”
  5. Select the “call wbvBrowser.GoToLink” script from the pop-out list
  6. In the script designer click on the “Text” Block, select the emptry String Block
  7. 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

ModderDojo Topic 4: Moving from Scratch to JavaScript

GeneralFeaturesOfProgrammingLanguages

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/

JavaScript is a well-established programming language, mainly used in web development. ScriptCraft is a Minecraft mod that allows you to write JavaScript code for building structures in Minecraft and writing new Minecraft mods. (So it’s a mod for creating other mods.)

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:

  1. Getting Started with ScriptCraft and JavaScript
  2. How to Connect to Each Other’s Servers
  3. 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/

Step 4: Comparing JavaScript to Scratch

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.)

This means that, if you already know how to write a Scratch programs that use these features, you will be able to apply that knowledge to any other language, such as JavaScript. The syntax of JavaScript is different, but it uses the same computational thinking.

Variables-Operators

Loops

Decisions

Notes:

  • Even though they have basic ideas in common, every programming language has its own specific commands that relate to its purpose: Scratch is focused on 2D games and animations, while ScriptCraft is focused on operating inside Minecraft, and JavaScript generally is used for interactive websites.
  • the echo command that features in these slides is not a standard JavaScript command, it is just used in ScriptCraft to display things on your screen in Minecraft.  Everything else is standard JavaScript.

Scratch Beginners Week 5 – Paddle Ball Game

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:

Season 5 Paddle ball - game design

First, we designed the paddle and made it follow our mouse, but only in the x-direction.

CDA-S5-Challenge_05_Paddle_Ball_move paddle

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).

CDA-S5-Challenge_05_Paddle_Ball_make ball fall

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.

CDA-S5-Challenge_05_Paddle_Ball_ball hit paddleCDA-S5-Challenge_05_Paddle_Ball_bc change score

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’.

CDA-S5-Challenge_05_Paddle_Ball_end gameNext 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!

Julie

 

Scratch Beginners Week 4 – A Better Ghost Catcher Game

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,Season 5 Better ghostcatcher- animate ghost - costume

Season 5 Better ghostcatcher- animate ghost - Code

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!),

Season 5 Better ghostcatcher- broadcasts

Season 5 Better ghostcatcher- broadcasts- make ghostcatcher react

We also got Ghostcatcher Bob to broadcast a message that makes the stage change it’s background to each time a level is changed.

Season 5 Better ghostcatcher- broadcasts - use score var to chg background color

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!

Julie OBeirn

Scratch Advanced: Week 3 Top Down Game Engine Part 1

A “Game Engine” is a piece of code you can use to build different types of games.  This week we looked at doing a top down scrolling game engine.  It’s still pretty basic at the moment but it’s enough to get started on some projects of your own.   What can you build with it?

Top Down Scrolling Game Part 1 Notes

screenshot-week1

Download the code for part 1 here.

Scratch Advanced: Twister Part 2

There was a huge group for today’s class where we took the Shape block from last week and built an amazing Twister project out of it.

We learnt:

  • more about angles and Sine and Cos
  • some basics of creating 3D illusions on a computer screen

week2

Twister Notes Week Two.

We didn’t get it quite finished, but managed to get to some 3D. Follow the notes to get to the end and check out this sample project that has all the pieces from the doc and a few extra features in. It’s addictive playing with the twister!

Download the completed project here!

Scratch Advanced: Twister Part 1

In Scratch advanced this week we learned some cool math formulas that are really handy for doing interesting stuff in programming.

week1

The things we went through!

  • We revised X and Y and reminded ourselves how it works
  • We drew a house using X and Y
  • We learnt about circles and radius
  • We learnt about the math formulas Sin and Cos and how they can be used to get X and Y positions on a circle
  • We learnt about Custom Blocks in Scratch
  • We wrote our own Custom Block that could draw a shape of any size and number of sides, using Sin and Cos to figure out the points!
  • We used that Custom block to make lots of neat patterns (some by accident!)

The notes are attached in PDF and if you follow them you will have a project ready to go for this Saturday – we are going to take that custom block and do some really cool things with it.    Don’t worry if you don’t have the time to do it or can’t follow the notes though – we’ll have this shared out so you can just take off where we finished!

Twister Notes Week1

Download the Scratch Code here!

Week 9 2015 – Scratch Beginners – Piano

Hello everyone,

Thank you all for coming yesterday on such a lovely day.

Thank you to Sean Shanley for demoing a 2D plotter that is controlled by Arduino, with 3D printed parts, and programmed with a Scratch variant called mblock.

The Arduino kits are available to buy on Amazon and the website where you can get all the ideas and instructions is called Instructables.

This week we did a simple Piano.

piano

We only had to draw two keys, and then could duplicate these and change the names. The same applied to the code. The code is the same for each key apart from one small change so the note is the appropriate for the key.

Piano2

Piano3

See you all next week, our last session before we have a one week break for the bank holiday and then we will be back working on individual projects, getting ready for our final day and the day we will award the belts.

belts

 

Here are notes from this week in PDF CDA-S4-Challenge-PrepareForBelts and Piano.pdf

Martha

Week 8 – 2015 Scratch Beginners

Hi everyone,

We completed our Mario game this week. We coded Mario so that he always floated down on to the wall. We added a fraction of a second of a wait so that it appears that he floats as he comes down. This also allows time for you to navigate left or right as needed.

CDA-S3-Challenge09-Scrolling

We also introduced a more advanced concept, the Parallax effect, whereby objects further away appear to move slower than objects nearer. We coded mountains and a Sun to demonstrate this.

 

You will a full version of the my notes in pdf form here. CDA-S4-Challenge09-Scrolling.pdf

Have a great Easter!

Martha

Week 7 – 2015 Scratch Beginners – Scrolling Backrounds

Hi everyone,

Thank you all for coming Saturday on such a nice day and such a busy day of sport as well!
We started our Mario game, where we will use scrolling of objects in the background to achieve movement rather than making Mario move.
scrolling

It can be a difficult concept to grasp for the younger ones, but we will go through it again next week before we continue on with the game.

scrolling2

Rather than putting up the notes from this week, I will wait until we have the game finished before putting up the completed notes.
I have however, put the game (as far as we did today) on the Scratch Website http://www.scratch.mit.edu. Login with the User name coderdojodathenry and password xxxxxxx123 and you will be able to download the game if you weren’t here this week or have a look at the code to get your own game work working.

MarioGame

See you all next week, when we will make Shrink and add some more scrolling sprites!

Martha