Advancers: Motorway Madness

This week in advancers, we simulated a true story!  Once Mark was driving past Athlone and encountered a car driving the wrong way down the motorway.  In this case it was a poor old gentleman who had somehow ended up turning down the sliproad, but we wrote a game which simulated the incident from a crazier drivers point of view!

The idea of the game was to drive as far as possible the wrong way down a 4-lane motorway before you crash.

The finished game is here if you want to play with it or look at the code!

Step 1: Draw the car

Out first step was to draw a car – we did this by switching to “Vector” mode and dragging a few boxes together – this is mark’s car below:


Step 2: Draw the road

The next step was to draw the road – the road was drawn the same way, using vectors.  One key point here was to space out the lanes more or less evenly, and to use the “Shift” button to ensure that the lines on the road were at 90 degree angles.  We drew the gaps in the white line using grey lines the same colour as the road.  A few bushes and buildings completed the scene!


Step 2: Make the road scroll!

In this game, we wanted the road to scroll from top to bottom.  This meant that the ySpeed of the road was negative.  We also wanted the road to move back to the top whenever it got to the bottom.  We had done side-scrolling with multiple sprites year ago in Explorers, and this was the same idea – however we managed to do it with just one sprite by using clones in the code below:



Step 4: Make the Car Move!

In this step we started off with basic movement – we were going to get to more realistic physics, but ran out of time!  I’ll see if I can show the code for this at the bottom and you can add it in yourself!

To make it move, we just checked for left and right arrows and added speed accordingly:


Step 5: Enemies!

The game was already starting to feel fun, but it’s a lot better with some unsuspecting traffic on the road!  We cloned the “player” sprite, and created a bunch of costumes to represent different styles of vehicle:

Next we wrote some code VERY similar to the scrolling background code for the enemy – this also reappears at the top when it reaches the edge – the difference being that it appears in a random lane and with a new costume.  This turned out great!

Final Step: Game Over

The final step was a “Game Over” text sprite – this shows whenever the player crashes!

This was a really fun game – I enjoyed making it a lot!

Exercise: Realistic Turning Physics

I said I’d have a go at realistic turning physics for the car – this code works and looks great – try adding it to your game to see what you think – basically it turns the front of the car realistically and the back skids around like a real front-wheel-drive car.  It was a bit tricky so I’m glad I didn’t push it as people would have gotten really tired as I tried and failed a few times!  Just pop this code into your “player” script anywhere near the end!


The game looks quite cool when finished!







Week 5 2018 Explorers – How fast can you type?

Hi everyone,

Thank you all for coming on Saturday. I hope you liked the short video of the SpaceX Falcon Heavy Test Launch and the Intel Light Drones from the opening Ceremony of the Winter Olympics.

This week we did a new game, How fast can you Type? Last week we used Sprites as backgrounds and this week we used Backgrounds as Sprites. Just to mix it up!

We used a variable as our Timer, our first time doing this, don’t forget if you want the time to start when you press the first letter rather than when the green flag is clicked then you are going to have to add another broadcast.

We are off for the next two weeks, to cover the school mid term break and also as Confirmation for all the Athenry Schools takes place on the 24th of February and there will be many families attending this from Coderdojo Athenry. Best wishes to any of our Ninjas and families who are being confirmed.

Hope you all have a great break and hope to see you all back on the 3rd of March

Bodgers – RPM & KPH

Last Saturday we had a look at how we might figure out how far and how fast a bike is going using a Raspberry Pi. We used a very basic set up with just a micro-switch attached to a toy trike with a little nut taped to the front wheel, each time the wheel rotates the nut would “click” the micro-switch.IMG_20180214_122408

We would need to use a reed switch or a hall effect sensor and a magnet attached to the wheel if we were to use this on a real bike.

We started of our coding by looking at the time.time() function. This function returns the number of seconds, in decimal form, since 01 January 1970. If we want to time an event all we have to do is use time.time() to get the start time and use it again to get the end time and then subtract the the start time from the end time.

We used this to get the the amount time it takes to do one rotation. Now we want to find out how many rotations we have per minute or RPM (revolutions per minute). As our result is in seconds the easiest thing to do is calculate revs per second so we divide 1 by the time it takes to do 1 rotation and then multiply the answer by 60 to get RPM.

Now we wanted to get KPH(kilometres per hour) so first we measured the circumference of the wheel and found it was 50cm or 0.5 Metres. We then calculated metres per minute by multiplying our RPM by 0.5 and we then multiplied this by 1000 to get KPH.

Here’s a picture of what our results could look like when displayed using Pygame. We will look at Pygame later on as it’s an excellent way of displaying information.IMG_20180214_122722

See you all after the break.

Declan, Dave and Alaidh

Week 4 – 2018 Explorers – Scrolling Backgrounds

Hi everyone,

Thank you all for coming again on Saturday and welcome to our new people!
This week we looked at some of the elements we will use in A Mario game we will make in a couple of weeks time.  We will use scrolling of objects in the background to achieve movement rather than making the Sprite itself move as we would normally do.
It can be a difficult concept to grasp for the younger ones, but we will go through it again before we make the Mario game.

Firstly we select our Sprite and we decided we would only move left and right.

We then had to create some Backgrounds. NOTE: EACH BACKGROUND IS A SPRITE. You do not create it as you normally would.

I have put the game on the Scratch Website Login with the User name and Password in the Notes Below.

Here are this weeks notes in PDF CDA-S7-Week 4-Scrolling.PDF

See you all on Saturday, we will do a new game that I think you will all like and maybe a little competitive!!!


Bodgers – New Kit & New Projects

Hello again Everyone.

Last week in the Bodgers group we began by looking at our new keyboards and Touchscreens. These will allow us to easily design touch based projects and projects that need a monitor. They will also be invaluable at the start of next years sessions as we can get our code on the Raspberry Pi straight away without any need to connect our laptops.


We also started planning our next project with a short brainstorming session and we have a couple of ideas we will develop further this week.


See you on Saturday.

Declan, Dave and Alaidh

Creators: Snake

This week we looked at creating a user-steerable snake in the style of the classic phone game.


Image from James Hamilton-Martin, Flickr

Things we need

The snakes head moves and the rest of the snake’s body is made up of places the head’s already been, up to a certain point. For this we use a JavaScript array (we’ve also called it a list at times).

We don’t want the snake’s length to grow indefinitely, so we have a maximum length. Once the list of stored locations gets larger than this, we use the JavaScript splice() command to remove the first (oldest) element from the list.

Direction and turning

Screen Shot 2018-02-06 at 22.59.28

We assign numbers to represent directions on the screen. Zero is right, one is up, two is left and three is down. Note then that if the snake is heading right (in the screen sense) and turns left it goes to up (in the screen sense); direction goes from zero to one. Similarly, if going up (in the screen sense) and it turns left then it goes to left (in the screen sense).

Generally then we note that turning to the left makes the direction number get bigger while turning to the right makes it get smaller. This rule hold until we get to a number bigger than three or smaller than zero; these make no sense. If direction is at zero and the snake goes right, we set direction to three. Similarly, if direction is at three and we turn left, we set direction to zero.

Getting this week’s code

As always, all the code from our Creator group can be found on our GitHub repository.