We put the call to background() in the setup() function because we didn’t want to clear the background every frame. After that, in the draw() function, we just needed to draw an circle at the mouse’s position every time the mouse button was pressed.

This gave us an very basic painting program in just a few lines of code!

Toolbar

We then looked at the idea of a toolbar to contain buttons for selecting colours and the size of the brush.

We first need to decide where it would be (the left side of the screen) and we created a variable toolbarSize to store the width of it.

In the draw() function we then added a check not to draw an circle if we were inside the toolbar area.

We then added a new function called mouseClicked(). This is a special function name (like setup() and draw()) that P5.js will call at the appropriate time. In this case its called when the mouse is clicked (button pressed down and the released).

Colour and Sizes

We created two arrays to store a list of colours and brush sizes at the top of our script:

To draw the toolbar, we made a new function called drawToolbar() and put a call to it in our draw() function. In the new function, we looped over the colours array, drawing a new button, filled with the respective colour and then another loop over sizes drawing a square with a circle inside to represent the brush size. We needed to scale those circles to make them fit inside our buttons.

Detecting Selected Button

Since everything in our toolbar was toolbarSize high, to determine what had been clicked on, we just needed to divide mouseY by toolbarSize to get the index of the button that had been clicked on. We looked at that index, if it was less than the number of colours, we must have clicked on a colour. If greater, it had to be a size (or beyond the end).

Selected colours and selected sizes were stored in two variables called currentColour and currentSize respectively and used within the draw() function when creating our circles.

Featured Artwork

Mark suggested that people draw a portrait of me to test our new program and there were some brilliant renderedings. Three people were kind enough to share theirs with me so that I could put them here. I think they’re great!

What did we do? This week in the Creators, our code was full of bugs, but that was okay :)! We created another project with classes and lists, this time creating an insect-like creature with a very simple mind – … Continue reading →

No notes this week, I will wait until we complete the game this Saturday.

Hope you all enjoyed the visit from Medtronic, we really appreciate the volunteers coming out to see us and showing us all the really interesting and exciting things they do….and the lollipops were lovely too.

This week we did some basic modelling in Blender. Blender is a very powerful 3D graphics package that is free and open-source. It is supported across all major desktop platforms.

Blender is so large and fully featured that it can be quite intimidating to learn. Knowledge of a few shortcut keys for common operations can really improve the experience of working with the program. We were indebted to Giuliano D’Angelo’s wonderful Blender shortcut infographic for providing us with some quick reference in this regard:

The first thing we covered in Blender was moving about. Practically speaking, Blender requires a three button mouse to operate. In Blender the middle mouse button (MMB) is used to control the view. Used on its own, it tilts the camera. When used with the SHIFT key, it pans the camera instead. CTRL and the MMB are use to zoom, but this is also more often achieved by scrolling the mouse wheel.

Object Mode and Edit Mode

We used Blender in two modes: Object Mode and Edit Mode. The TAB key can be used to switch between these. In Object Mode we can create, select and reposition objects but we cannot do any detailed editing on them. In Edit Mode, we can do any detailed editing we require on the currently selected object. Note that selecting items in Blender is done with the right mouse button (RMB).

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.

These are the notes from our seventh challenge in Season 2 of Scratch Beginners, CoderDojo Athenry.

The challenge this week was to work on your own game. The coding concepts for this challenge are:

Using the Scratch skills you have acquired for your own games

Creativity and imagination

Designing your own program.

A key point in developing your own game is to start simple, get the first idea tested and working, and then start adding more. We also spoke about the usefulness of planning on paper, rather than jumping straight into coding (which can be a tough one to sell!)