Remixing Scratch Projects

There are many things to love about Scratch. The online Scratch community is definitely one of them. All shared projects in Scratch are public and available to everyone to use and examine how it was built. Furthermore, all shared projects can be ‘remixed’ which creates your own copy of the project for you to modify. This is incredibly powerful as you can ‘leverage’ (re-use) the work of others to use as a starting point for your own project or simply use parts of it to integrate into your own work. I will demonstrate both.

In this post we will look at several Scratch projects that I have re-mixed. I will then describe how to remix the project that I created and make some modifications of your own.

Asteroids Tutorial by RokCoder

A few weeks ago I was searching for some old (retro) games on Scratch and found many versions of a classic game called Asteroids. Some were simple and some were very complex. Then I found this tutorial in Scratch that sounded really interesting:

The instructions read:

This tutorial takes you through all the steps required to create your own high quality game of Asteroids in Scratch. Simply run the tutorial and follow the instructions that it gives.

What an awesome concept! A Scratch project that teaches you how to build a Scratch project. It provides some of the base code, sprites, sounds and then guides you through creating the rest. I did the tutorial to see if it would be suitable for my students. It was quite complex in the end, probably too difficult for most of my students, but I still loved the idea. Thank you RokCoder!

Version 1.1 – Adding basic features

After I finished RokCoder’s tutorial I decided to make some changes to the code, clean it up, simplify it and then thought about some features I could add. The goal of the tutorial was to help you create a fully functioning game and then encourage/inspire you to add the other features yourself. I was definitely inspired.

One of the first things I wanted to add was a scoring system and a nice way of displaying the game stats on the screen. I had remixed some ‘pen text engines’ before so after a quick search I decided to incorporate djPro’s pen text engine into my project. This allowed me to display the game stats like the level, score and shield health. Yes, I also added a shield that could withstand a certain number of collisions with asteroids to make the game last longer. It still had some bugs, but I was pretty happy with it for v1.1. If you are using an iPad you can’t play this version as it only has keyboard controls.

Version Control

When you are working on a project it’s a good idea to create copies of your code. This is called version control. In Scratch it’s easy to do – just click File -> Save as a copy. I then renamed the project as v1.2. Why would I do this? I wanted to keep a working copy of version 1.1 just in case I accidentally messed up the project as I was making changes. This way I could always go back to version 1.1 and start again or copy code that I might have deleted or mucked up. All professional software developers use some kind of version control to safeguard their work. The last thing you want is to lose hours, days or weeks worth of work. It has happened to many – don’t let it happen to you.

Version 1.2 – Multiplayer Mode

Adding multiplayer mode was going to require a lot of changes so creating a new version of the code was a smart thing to do. If you look inside this project you will see that the number of sprites increases from 8 to 13 between version 1.1 and 1.2. This is not remote multiplayer as both players need to be using the same computer. Player 1 uses the arrow keys and player 2 uses the WASD keys. There’s also a way to pause the game.

Version 1.3 – Bug fixes, winner message and simplification

In this version I didn’t add any major features except for an extra message in multiplayer mode announcing the winner which isn’t a major feature. What I did do was to fix some bugs that I had discovered and simplify the code by reducing the number of sprites down from 13 to 10. This is something that professional programmers do a lot. Simplifying code makes it easier to understand and easier to add more features. Sometimes code gets very messy and difficult to work with – this is known as spaghetti code. I love spaghetti, but not in my code. Neat code is good code.

Version 1.4 – Mobile Friendly Controls

In this version I decided to add on screen controls by remixing code from another project by AtomicMagicNumber who built a very cool Tetris clone.

Leveraging the work of others

Borrowing code like this is not stealing or cheating as this is how the Scratch community has thrived. We learn from each other and give credit to others that we have learnt from. When we share our projects that may help others too. It’s the ‘pay it forward’ model and it works. Being able to re-use or leverage other peoples’ work has not just saved me time, but has allowed me to create something that I simply wouldn’t have been able to on my own.

By version 1.4 I have now remixed or used the code from 3 different projects and Scratchers. I had spent many hours putting it all together and adding my own code too. Now it’s your turn…

Step 1 – Remix Asteroids v1.4

This should be the easy step as all you need to do is first login to your own account and then find my project (in the class studio) and click the remix button.

Make sure you login before you remix

Step 2 – Rename the project… hmmm?

You should rename your project as it will probably have a name like ‘Asteroids v1.4 remix’. We are going to make some small changes to this game so now is a good time to think about what you will do. I’m going to how you can replace 5 things that will dramatically change how the game looks without changing any code. You don’t have to do all of them. The list of changes are:

  • Backdrop
  • Sound effects
  • Spaceship
  • Asteroids
  • Title

Step 3 – Change the backdrop

Let’s start with the simplest change. The project only has 1 backdrop so replacing it should be straightforward. You simply click on the stage, add a new backdrop and then delete the original. You can use a Scratch background, download one from Google images or make one using PosterMyWall.

Step 4 – Change sound effects

If you listen to the sounds of the game you will notice that there are quite a few:

  1. Laser fire (pew pew) – in the bullet1 and bullet2 sprites
  2. Explosions (3 variations) – in the explosion sprite
  3. Level up (win) – in the game sprite
  4. Game over (lose) – also in the game sprite
  5. Beat (beat1 and beat2) – yep, in the game sprite

You should change at least 2 of these sounds. You don’t have to change them all. You can modify the sounds, replace them with other Scratch sounds, record your own or upload sounds you’ve found by googling. Just remember that the beat sounds are supposed to be very short as they are repeated very frequently and increasingly quickly.

Make sure the sound names stay the same otherwise the code won’t play them.

When you replace a sound you should delete the original and give it the same name. This way the code that plays the sound will continue to work. If you find the sounds are no longer working then you probably forgot to rename it or didn’t get the name exactly right. For example in the game sprite you should have 4 sounds: beat1, beat2, Lose and Win.

The explosion sprite sounds should be named: bangLarge, bangSmall and bangMedium

The bullet sound should be called: fire

Step 5 – Change spaceships

The player1 and player2 sprites have 3 costumes that very small differences (the flames coming from the engines). The code changes the costumes 1 per second to create a barely noticeable animation effect. You can change the spaceships to be something totally different, but they should be about the same size otherwise you might also have to adjust the size of the shield sprite (which should be easy). You don’t have to have multiple costumes for the player1 and player2 sprites, but since the code is already there it might be a good idea to have a small animation effect. You could use the pixilart or piskelapp website to create an animated GIF – just make sure the background is transparent. Don’t forget to place your sprite at the centre of the canvas and face it to the right. More tips here.

The costumes will change once per second … unless you change the code

Step 6 – Change asteroids

If you made it this far you’ve done very well. By now your game could look and sound totally different from the original, but there’s one final element to change – those rock things! I mean asteroids. When you look at the costumes tab in the asteroid sprite you will notice there are 3: large, medium and small.

You probably worked out that in the game each asteroid starts by using the large costume. The first time it is hit by a bullet or the shield it breaks into 2 pieces both using the medium costume. When a medium asteroid is hit it breaks into 2 small ones. Finally when a small asteroid is hit it is destroyed (or probably becomes lots of dust particles).

If you change these costumes you will have to replace them with 3 similarly sized ones. Well, they don’t have to be, but it might be a bit weird if they started small and grew larger. Remember, that the costume names should still be: large, medium and small – otherwise the code may not work as expected. The order must also be the same as the code uses the costume number. Oh and make sure the costume is in the centre where the crosshairs are.

Remember to keep the costume names the same as the originals.
Are those fortune cookies?

Step 7 – Change the title

I forgot to mention that after each step you should be testing the game to see if it still works as expected. This is one of the best things about game development – you get to play your own game as part of your work.

Ok, the final step is to give your game a new name. The title is contained is a costume in the ‘Game’ sprite. I used white text which is very hard to see on an almost white background in Scratch. If you didn’t rename your project in step 1 you should definitely do it now that your game is finished.

If you are using a light coloured background you will need to change the text colour of the other costumes in this sprite too otherwise it may not be easy to read.

Step 8 – Change explosion animation, shield and bullets

I almost forgot about this. This step is definitely optional, but I thought I might as well cover the last few sprites.

The explosion sprite has 8 costumes to animate the explosion which I must say is pretty nice. The code changes costumes very quickly so you should consider this if you want to change the look of the explosion. If you change the number of costumes then you will need to adjust the code.

There is only 1 costume for bullet1 and bullet2 so it’s easy to change if you want to. BTW bullet1 is for player1 and bullet2 is for player2. I’m sure you guessed that right? The same is also true for Shield1 and Shield2 – 1 costume each. The size of both the bullet and the shield are quite important in the game. The shield must be slightly bigger than the player sprites otherwise it won’t protect it from whatever obstacles you have floating around. The bullets should be small – the originals are only 5×5 pixels. If you make them bigger… I’ll let you figure out what the side-effect is.

Step 9 – Share your project to the class studio

You should be very good at doing this by now. Make sure you give your project an appropriate name, click the Share button, then click the Add to Studio button on the project page and select the class studio and click Okay. Done.

3 Comments

  1. Gabriel Armanyous

    This is gonna be hard

    Reply
    • Anonymous

      Yup

      Reply
      • Anonymous

        Yep

        Reply

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *