16 September 2016
Whenever we're on holiday, if there's a maize maze or a hedge maze nearby, we always take a look. Mazes fascinate me.
So when it came to planning projects for Cool Scratch Projects in Easy Steps, I thought it would be interesting to include some maze games. In my previous book Scratch Programming in Easy Steps, there's a chapter of seven short projects at the end and one of those was a really simple script to enable you to move a dot through a maze without being able to walk through walls. Although it's a short project, it was really popular, so I know many readers share my interest in mazes.
As a result, there are three maze projects in Cool Scratch Projects in Easy Steps. The first is Maze Maker, which will generate a random maze for you based on a grid you provide it. You can save an image of the Stage, and reload it as a sprite or background, so you can use the mazes generated by this project in pretty much any game. This project was an opportunity to show how you can make more complex programs, and it uses a technique I previously used for my Minecraft Maze Maker, which appeared in Raspberry Pi For Dummies and Raspberry Pi Projects. Here's a video of it in action, drawing a brain shaped maze:
Then, there's a game called Circuit Breaker, which uses mazes generated in Maze Maker. In this game, you have to track down as many bugs in the circuit as you can in two minutes. The time pressure makes it quite a tense game, because you often have to move on instinct rather than trying to trace the entire route before moving. As with all the projects in the book, I've included suggestions for how you can expand on them and one of my favourite ideas for customising this game is to award bonus time when you catch a bug. I'm sure you can think of other things you can do with this project. Here's a video of it in action:
The third maze project is a 3D Maze Explorer, which enables you to walk through a maze. You move by turning left or right and then walking forwards or backwards. The arrow in the top left is a compass that points north. The maze can be randomly generated, using the Scratch Maze Maker project, or you can design it yourself. The book shows you how to get the script working with both types of maze. It also shows you how to add collectables (cakes, in fact!) to your hand-designed mazes, and you can adapt the script to add them to random mazes too. Here's a video that shows me playing the game. At times it might be a little bit confusing because you can't see which keys I pressed and I've gone through it quite fast, but the game feels natural when you're playing it. It starts by scanning in one of the random mazes.
Cool Scratch Projects in Easy Steps is hot off the presses and in the shops now! My previous book Scratch Programming in Easy Steps is also available, and the two complement each other nicely, with "Cool" showing you how to build specific cool projects, and "Programming" going into greater depth on how the Scratch programming language works.
09 September 2016
We've come a long way in bringing coding back into schools in the last few years, but I think there's potential to more closely incorporate it in other aspects of the curriculum. In the same way that writing and maths are used in most other subjects, as ways of expressing ideas, coding can be too. In the arts, the computer can be a great tool for creation, with randomness and serendipity adding to the creative process. (If you're interested in random art, check out my review of Brian Eno's 77 Million Paintings). Computers can also provide a way for people to express themselves through music or art, even if they are not talented with an instrument or pencil.
The first music project is a drum machine that you can customise with your own sounds (in Scratch 2.0) and use to program your own rhythms. Each row represents a different sound, and each column represents a beat. If the spot at a particular point is turned on (blue), that sound will play on that beat. Here's a video of it in action:
I've also provided some synthesised note samples for download that you can use to turn this Scratch project into a melody machine, so you can use the same program to play evolving tunes, like this:
The second music project is a random tune generator, called Scratch Cat Maestro. I used the C Major Pentatonic scale for this, but you can use any scale. The tune is only 32 notes long, but I used the pattern AABA to repeat bits, so it feels like there is some structure and it's not just a stream of random blips. It ends on the root note, so it feels complete. Some tunes come out better than others, obviously. Here's a demo:
For both books, I wrote a chapter at the end with a few short and sweet programs that readers can quickly dip into. Both books had a random art project in this section. In Scratch Programming in Easy Steps, the project is called Abstract Artist and created line-based patterns. For Cool Scratch Projects in Easy Steps, the art project is called Going Dotty and creates hypnotic circle patterns.
I have a keen interest in electronic music today, and first started experimenting with it by programming an Amstrad CPC464 in BASIC. I hope that these Scratch projects will show readers new ways of making music and art on the computer, and will inspire them to experiment with customising these projects, or designing their own.
For more information, visit the homepages for Cool Scratch Projects in Easy Steps and Scratch Programming in Easy Steps. You can order Cool Scratch Projects in Easy Steps here, and Scratch Programming in Easy Steps here, with further links to buy my books here.
10 August 2016
I can now reveal the free gift that comes with the print edition of Cool Scratch Projects in Easy Steps: it's a pair of 3D glasses. They're the red/cyan coloured lens type (called "anaglyph"), and the book has three projects that show you how to use them to make 3D effects with images that pop out of the screen or sink into it. There's a game called 12 Angry Aliens, where you have to zap the aliens that rush towards you; a 3D art package that enables you to position shapes at different depths, and a game called Space Mine 3D that shows off the depth you can achieve with a nice tunnel effect. You can see all the projects here, although the videos for the 3D projects will make more sense if you have a pair of 3D glasses. If you are buying the ebook, lose your glasses or want another pair, anaglyph glasses are available cheaply online from Amazon and eBay.
Cool Scratch Projects in Easy Steps is now expected to be available 12th August, rather than the end of the month, so you can get started on the projects over the summer holidays. You can get a special launch price by ordering direct from the publisher, and be one of the first to get your hands on a copy of the book!
Here are some photos of the book being printed.
And here's the first photo of the first copy the publisher received! It's nearly here! I'm getting excited...
28 July 2016
Now I've finished writing Cool Scratch Projects in Easy Steps, I'm going to start uploading the examples and supporting content as we approach publication. By publication day, you will be able to find the projects in the official Cool Scratch Projects in Easy Steps studio on the Scratch website. I hope that you'll agree that the projects in this book bring something fresh and exciting that you won't have seen somewhere else, and that they can live up to the label of being 'cool'.
The projects won't necessarily be shared in the order they appear in the book, but I thought I'd start with the first one. Magic Mirror is a new spin on the 'cat going for a walk' project which starts many tutorials, including my previous book Scratch Programming in Easy Steps. In Magic Mirror, you move the cat using the left and right arrow keys, with the up key to jump. When you walk in front of the Magic Mirror, you see your reflection. Jumping into the buttons changes the mirror's settings, with different distorted reflections available. It's like a fairground's hall of mirrors, reimagined. This is a fun short project that shows you how to use graphic effects and layers, and introduces some ideas that are used in the more advanced projects later in the book.
Cool Scratch Projects in Easy Steps is available for pre-order now and will be released 31st August. Amazon's pre-order guarantee means that you will pay the lowest price they offer until the publication date if you pre-order now. If you have any questions, feel free to ask in the comments below, although we're saving a surprise for a bit later on so I might not be able to answer everything...
The project is embedded below:
12 May 2016
UPDATE: The Scratch team has now fixed this bug.
My book How to Code includes a buzzer game project. There's a bug in Scratch at the moment, which means the arrow sprite doesn't face the direction of travel. When you add a sprite, its default movement direction is right, so sprites are usually drawn to be facing right. The arrow1 sprite, however, points up when it is loaded.
This is a new thing, because it wasn't the case when I wrote and tested the game and it isn't the case in my downloaded version of Scratch 2.0, which is older than the current online version.
If you are experiencing this problem, you can fix it by adding a block to set the costume to the correct one at the start of the game, as shown below.
04 March 2016
The March 2016 issue of The MagPi is out now, featuring my project Clef Hero. The game uses the Piano Hat, a tiny music keyboard that fits on the top of the Raspberry Pi, to teach you to read sheet music. I made it for myself first of all, but it provides a good example of how the Piano Hat works and will hopefully help others to learn too. I don't read music fluently, especially around the leger lines, and many years ago I learned chord fingering using a program I wrote for the Amstrad CPC (pictured, right), playing my keyboard while watching the computer screen.
In the Clef Hero game, you are shown the treble stave and notes appear on it, which you then have to hit on the keyboard. The keyboard only has one octave on it, so the same key is reused for the same note in different octaves. The game starts easy with a small selection of notes, but gradually adds more notes and introduces sharps and flats until you're working with the full stave.
For its musical notes, the project uses Sonic Pi, so my tutorial also explains how you can use Sonic Pi to generate a scale and then use Audacity to turn it into separate note files that Clef Hero can play. You can find a guide to note numbers in Sonic Pi here.
The game is written in Python, using Pygame Zero.
Here are the links you need:
- Download The MagPi here - it's free as a PDF, but you can support the Raspberry Pi Foundation's educational mission by buying it in print or through the Apple App Store and Google Play Store.
- Download the Clef Hero Python code. - It downloads as a text file. Rename it to clef.py.
- Download the Sonic Pi code. - It also downloads as a text file. Rename it to listing1 or copy and paste it into Sonic Pi.
For more information on Sonic Pi and Python, take a look at the book I co-wrote with Mike Cook, Raspberry Pi For Dummies.
With thanks to Gerd Altmann who created the background design I'm using here.
10 February 2016
Writing a book can be a solitary business, especially for self-published novelists. I had a policy of not discussing my novel while writing it, because I wanted people to be excited by the book when it came out and not bored of hearing me talk about it. But that meant I overlooked an important step in the book's lifecycle: that of testing the cover and title with its audience before proceeding to publication.
My novel is a techno-thriller set in the music industry, and involves a conspiracy where a record label sells computer generated music to fans, without telling them the bands are fake.
It originally came out under the title University of Death, named after the "real" band that gets mixed up in the action. The cover design was a stark black and yellow silhouette of fans with their raised arms at a concert. The cover and title were distinctive, but they didn't reflect the book's content well, and some people were put off by what they thought was a zombie story. Given that most of my non-fiction books are about programming and website design, it was a real kick-self moment when I realised I'd failed to test the end product with its audience before releasing it.
When I came to publish the book on Kindle recently, I decided to get some more brains on the case. I started by running a brainstorm on Facebook to invite people to suggest a new name for the book. I had really struggled to come up with a good name, but there were lots of brilliant suggestions from my friends. I filtered out the titles already claimed for erotic fiction novels (my, those authors are prolific!) and those encumbered by trademarks or other business activities (I was particularly sorry to see Spytunes and Autotuned struck off the list). Finally, I chose the title 'Earworm', suggested by my friend Andy Lawn.
For the cover, I ran a design competition through 99designs.co.uk. You provide a brief, and the site's talented community of designers submit designs to meet it. After some rounds of feedback and shortlisting, you pay £189 for your chosen design.
Almost immediately, a design came in that I thought was a contender to be the final winner. It looked professional and it had dramatic typography that wouldn't look out of place in an airport bookshop. Even as some great other designs came in, it remained a favourite. When I had a few designs in, I put together a shortlist and ran a poll among my Facebook friends. Guess what? My favourite cover ranked fourth. Out of six. It looked like a war novel, somebody said, and they were right.
This was when I had to trust the crowd. It might be my book, but it needs to appeal primarily to my readers, and my friends represented those readers in all their diversity much better than any one person could. They identified a cover with much broader appeal, that better reflected the themes of the book, and which I'm pleased to say I've grown to love.
I've learned that whether it's for a brainstorm, or market research, one of the best assets an author can have is a network of friends who can provide a fresh perspective on the big decisions. Thank you to everyone who helped me. It made a huge difference.
Find out more about Earworm and see the final cover here. Earworm is out now on Kindle and in print on Amazon.
Photo shows Display Stand with Brains by Katharina Fritsch