Sonic 4 Scratch

0 views
Skip to first unread message

Elwanda Menhennett

unread,
Aug 4, 2024, 11:07:25 PM8/4/24
to bundmalimeaf
Idon't know if any of you are familiar with the website soahcity.com, but I sure was. It was where I got most, if not all of my Sonic music, and where I got the first music I put on my iPod. The site meant a lot to me. A few months ago, it went under "construction" and got a new "manager" (the founder was still there, but he's always been busy doing real life things). I don't know when this happened, but apparently the site got hacked, and now Neon Chaos is done with it. No more construction, no more forums, nothing.

Not that the site as a whole was anywhere near as dedicated as we all are here at Retro, but I find it sad that a Sonic site that had been around for twelve years is now gone, and the owner has given up on it. It was never a large website, but I just wanted to, well, pay some respect, I guess, to the site where I got about 50-60% of my music library from. Do any of you guys have something you could say about the site?


Man I remember SoaH from back when I first started using the internets too.. even recently, last year sometime I had downloaded many Sonic soundtracks there when I couldn't find good torrents or packs for them.


...well dang it. I never knew it was a sonic fan site I thought it was a music downloading site, that's where I got paranoid dj's awsome mephiles' whisper remix and his world remix. I actually got most of my sonic music from brawl custom music when they had mp3 downloads.


I also have memories of SoaH, it was where I would found out about the OSTs of the series and it was the first forum that I ever joined. I remember there was a member there named Snatcher that would buy the CDs and would share with us how the CD looked, mp3s, and where to get them in case we wanted to buy them too. It made me want to buy and start collecting the CDs.


I used to visit it all the time before coming here. I provided a lot of the music for the site early on, including a lot of line-in recordings if the OSTs weren't available yet, so I do have some attachment to that site. Haven't been there in ages, though.


Yeah Goku way to make me feel old, and I'm the same age as Solkia, SoAH is not THAT old, when it got it's new facelift I stopped caring because I remember the black layout it had with red text made it the cool and edgy dark sonic forum with all the music, darkspeed's SA2 comic and of course all the fan wallpapers, and official ones SEGA released, if that's all gone then we may have lost a piece of SEGA history since that was the only site that comes to mind that still had all the old Sonic Channel wallpapers, screen savers and even the ultra rare SA2 on-disc screensaver that no one can run any more, they also had all the SA wallpaper, it probably had the largest backlog of Sonic Music ever though, but after the server crash and wipe, they lost a lot of the old music and game Rips that they never replaced.


Sad to see it go. SoaH was one of the first Sonic fansites I ever found and was a great place to get music and wallpapers. In somewhat more recent years (around 2007-2009), I even posted on the forums quite a bit and made some of the "LOL Sonic" pictures.


EDIT The python script in this article has been changed to allow for the recification of a bug in gpiozero which has been corrected in version 2. Also, if you use the latest version of Scratch 3.30.9 then the system will now work on the latest FRaspberryPiOS (Bookworm) and on a Pi5 and on the latest version 4.5 of Sonic PI. ON additional line is added to the python script and this is detailed in the github source referenced at the foot of this article. You also have to run Python in a virtual environment on Bookworm in order to add the required python-osc module. Again ther are details added to the github FREADME file about this. The performance on a Pi5 under bookworm is considerably better and more responsive than in the orginal version.


Several years ago I had a brief play with an OSC interface which let you communicate with an early version of Scratch. Unfortunately it was not compatible with later versions of Scratch, but Scratch3 on the Raspberry Pi now has several add-ons incorporated including one to allow it to interact with the GPIO pins. I have already done several projects with Sonic Pi together with a python script acting as an OSC server and client to allow Sonic PI to communicate with the GPIO pins using the gpoizero library so I decided to experiment and see if I could produce something which would let it communicate with Sonic Pi. The result is this project, which lets Scratch3 act as a virtual keyboard for Sonic Pi, which can either be used to play notes, or as a trigger to control the sounds that Sonic Pi is producing. It is not perfect and suffers from a certain amount of latency, which is unfortunately variable, but nevertheless is fun to do, and I think that the end result will be appealing to scratch and sonic-pi users alike.


As you can see there are 20 green buttons, each of which represents a different note in teh range. The main note keys are named, with the interspersed smaller buttons representing #/flat notes. When the mouse is held over one of these buttons with the mouse button down, it alters one of the GPIO pins and the python script sends an appropriate message to Sonic PI. When the button is released (or the pointer is moved off the green button, the GPIO pin reverts to its normal state, and another message is sent to Sonic Pi.


The heart of the code is associated with each of the 20 green buttons. You can click it to see an enlarged copy. It shows the code for button1. Every button has the same myblock defined, named blippin (short for blip input). Looking at this block code, it has one parameter which is named pin. This is the number of the GPIO pin (in BCP numbering) associated with the particular green button in question. For button1 it is in fact GPIO pin BCP 1. The my block is called by the associated code consisting of a Green Flag followed by blippin 1

The first action line of the blippin block in light blue moves the green sprite to an x y position which is stored in two lists one of x the other of y coordinates, with an associated lookup list which relates the GPIO pin number (which follows a sequence I chose) of 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 for the pins in use. I chose these to avoid pins used by the Pimoroni Fan Shim which I have connected to my Pi4 so that they could work in harmony together. Using the lookup list which contains:

1,2,0,3,4,5,6,7,8,9,10,11,12,0,0,13,0,0,14,15,16,17,18,19,20 lets the correct entry in the x,y coordinates to be chosen. So for example if we are looking at the sprite Button3 this actually has 4 for its pin number. The list shows entry 4 is the number 3, so it will chose the third entry in the x,y coordinate lists. The reason for having these lists and the goto x,y command is that it is very easy to inadvertently move the buttons, and this ensures that their positions are reset each time the program is run. The beginnings of the three lists are shown below.again, you can click the image to see a larger version. Once the position of the button has been adjusted, the next line of the blippin myblock starts a forever loop which continuously controls the state of the GPIO pin associated with the block. If the mouse pointer is inside the green sprite and the mouse button is down, it changes the state of the pin to be low, and keeps it there until either the mouse button is released or the pointer is moved off the green sprite.


code. That completes the Scratch3. However, before loading the file you should select the Raspberry Pi GPIO extension from the blue extensions tab bottom left on the Scratch3 screen, as this code is essential for it to work.


The OSC server is set up in the __main__ part of the script towards the end. This first of all sets up a parser to receive and analyse the input parameters. Often none will be supplied if Scratch2 and Sonic PI (3.2.2) are running on the same Pi and default values will be employed (127.0.0.1 or local host for the ip address on which they are both running, port 4560 for osc messages sent to Sonic PI and port 8000 for messages sent to the python server). However, if these are on different machines, then you must specify the ip address of the Pi and the ip address of the computer running Sonic Pi using syntax as below.


IN this latter case 192.160.1.150 would be the ip address of the Pi and 192.168.1.129 the ip address of the computer running Sonic Pi on the same local network. Note the execute bit has to be set on the script to run it directly like this


All the code is available from my github site

A video of the project in action is available here

Final note. Since writing the article and making the video I have slightly altered the position of the sprites on the screen. This affects the values in the ylist in the scratch program but nothing else.


Creating games on Scratch is both fun and educational as they help any new beginner to understand the basics of coding and game development while creating amazing and innovative games. Users have created many popular games on Scratch like Pac-man, 3D games, Geometry Dash, and many more!


Sonic game is one of the most popular games among kids in which the main character has to move or jump to avoid all the obstacles coming his way and move onto the platforms for moving forward in the game. It comes in the category of platform games.


We hope you understand how to make a sonic game on Scratch. If you have any doubts, you can ask your doubts in the comment section. If you found this game interesting, then read more of our game tutorials like game with levels, multiplayer games, Pac-man game, and many more!


aw that looks so cool! didnt someone already make a sonic engine in blender like, forever ago? are you using that engine as a base, or are you starting from scratch? if your starting from scratch then this is very impressive. I always did want to make a sonic fan game, since i love the character, but I never really had the drive to try and get him just right in blender. Always wished i could use the old sonic blender game as a base and start from there.

3a8082e126
Reply all
Reply to author
Forward
0 new messages