Snake (And How I Made It)

Snake (And How I Made It)

by Ironisgold

πŸ‘ 209 ❀️ 19 ⭐ 12 πŸ”„ 0
Created: Aug 8, 2022 Last modified: Sep 25, 2023 Shared: Aug 17, 2022

Description

Run using turbowarp for best experience: https://turbowarp.org/720304756 Just a recreation of the classic game snake. I tried making it in python with turtle but that was way too slow and annoying to work with so I resorted to using scratch. The game doesn't run as well as I would like but I've optimized it as much as I am able. ^This was an incorrect statement I came back to it and found a couple things that needed improving so the game runs much faster now ---------------------------------------------- How the game works (Kinda complicated but interesting): Let me know if you have any questions by leaving a comment! (I will try my best to answer them) The game uses a grid system that is labeled a-r for both the x and the y axis. This is because it is able to fit the coordinates into just one digit per axis. This is very important because when the script is interpreting the coordinates it needs to know which is which. With this system it knows the x is the first digit and the y is the second digit. If there were more digits there would have to be a way for it to know which numbers are for x and which are for y which would further complicate things. The system I used is easy and simple. The coordinates of the body of the snake are stored in a list, and when the snake moves the last coordinates are removed from the list, and the new coordinates (where the head just moved to) are added to the list. The script then checks if the new coordinates are already in the list, and if so that means that the head and body are overlapping. When they are overlapping that means the player loses and the game ends. The coordinates are stored by taking one axis and simplifying that number to a multiple of one, which would be from 1-17 since that is how many squares there are. It then takes the number and sets it to whatever letter represents it. This would then give you a pair of letters (one for each axis) which would look something like cg or ii (ii would be the very middle one). The coordinates start with a in the bottom left, and then working there way outward alphabetically. The detection for hitting the edges is very simple and complicated at the same time. It is basically using a quirk of Scratch where if the coordinate is greater or less than 1-17, Scratch will not be able to assign it a letter because there are no letters assigned to those numbers. So what Scratch does is it just leaves it blank, instead of giving it a number. If one of the numbers is blank (ex: it could just be "g" because the other letter is missing) then the script will see that it is only one letter long and so it knows you went out of bounds. I hope that made sense. For detecting the food it just compares the food coordinates to the head coordinates and if they are the same then the snake is touching the food and will eat it. The food then teleports to another random location. When the snake eats the food, instead of the script removing the last coordinates like I mentioned earlier (talking about when the snake moves) it will just keep the last coordinates, and then also add the new one where the head moved to which would make the snake one longer. Lets say the snake is going straight up. The coordinates could look something like "ic", "id", "ie". Normally it would then remove "ic" which was the bottom one, and then add 'if" which would be the next one. The list would now be "id", 'ie", "if". Note that the list is still 3 long. Now if we go back to 'ic", "id", "ie" and this time don't remove "ic" but still add "if" we would get "ic", "id", "ie", "if" which is now 4 long meaning the snake has grown by one. You can see this when playing. Notice how when you eat the food the very end of the tail doesn't move for 1 turn. I really hope that made sense. I think that is the worst of it so if you got that you should be able to understand everything else. Lastly there is a sprite that uses pen to draw the body starting from the head, and then going through the list of coordinates until it gets to the tail. To make the tail move smoothly I added a little bit at the end that slowly goes out less and less far making the tail seem like it is smoothly moving along with the head. The UI stuff like highscore and world record at the end is very simple. If the score is higher than the highscore then it will set the highscore to the score. The world record works the exacts same way, and is a cloud variable. #all #games

Instructions

See how I made the game in the notes and credits below Use WASD to control the snake Don't hit the edges or run into yourself Eat the food for points and to grow longer

Project Details

Visibility
Visible
Comments
Enabled

More Cool Projects

Project thumbnail
View Project

Add Yourself/OC In FNF Knockout Remake

by justaBFBfan_lol

Project thumbnail
View Project

Zoomscript

by -llll-

Project thumbnail
View Project

Gifts | Speedruning Christmas Platformer [Mobile]

by KnocbacGaming

Project thumbnail
View Project

New Super Mario Bros V.2.11

by Heysbeauz

Project thumbnail
View Project

Cloud Orchestra

by codeGIO

Project thumbnail
View Project

osu! Full Remake

by SpiritSK

Project thumbnail
View Project

Battle Bound v1.37 space map

by green-lantern-11

Project thumbnail
View Project

[UT: Endless Breath] Act 2 [Re-Remastered] (OG sprite)

by Multiverse-modes

Project thumbnail
View Project

Parappa the Rapper Scratched

by coldmaster12345

Project thumbnail
View Project

Super StickMan Run *New Update!*

by NickFanboy115

Project thumbnail
View Project

不俑パピルス 第6ε½’ζ…‹ Disbelief Papyrus Phase6

by exhisa

Project thumbnail
View Project

Friday Night Funkin' Vs. Kapi Mod | Nyaw

by CharizardAaroshdude

Project thumbnail
View Project

β€”ε˜η΄”γ«β€” #games #tantan9024

by tantan9024

Project thumbnail
View Project

Numberblocks band 256ths 87-92

by yyyy-21209

Project thumbnail
View Project

☁️ Backyard Brawl

by Aderos68O1

Project thumbnail
View Project

Eggman Final Boss Sonic remix

by FRIENDLY_ZAPP

Project thumbnail
View Project

Fnf week T (Vs TrollFace)

by keith_coatpose

Project thumbnail
View Project

γƒžγ‚€γ‚―γƒ©

by SMG1126

Project thumbnail
View Project

Run 3 remix

by srtrt

Project thumbnail
View Project

テラγƒͺγ‚’γ€€ζ—₯本θͺžη‰ˆ

by yamaguchi03

Project thumbnail
View Project

The Object Show Movie THE FINAL EPIC BATTLE Part 29

by TheScarfedStickman

Project thumbnail
View Project

Double Date Playable - Rhythm Heaven Fever

by subskybox

Project thumbnail
View Project

REVIVAL - SCRATCH HACKATHON 2023 - BRYCE OOI YU XUAN

by BryceOoi

Project thumbnail
View Project

Minecraft clicker! A 3.0 clicker game [#Games #All #Minecraft #maDU59_]

by maDU59_