Oh [Applause] [Applause] [Applause] [Applause] [Applause] hey what’s up guys i’m just going to take this opportunity to explain how some of the parts of tetris actually work a lot of them are really cool i spent a lot of time on it so why not right um this is the color coded version i Have on my server i don’t actually just build an iron block some yeah i do color code i swear so this purple is what’s being displayed on the screen these are just kind of like mini displays to resemble the screen so the purple is what’s on the screen And then the red and blue are like the internal parts of the machine so we have the red part whatever is being displayed on the red gets displayed on the purple and then same thing with blue so if we have something over here it also gets displayed on the purple so That’s how those work so the purpose of these two types is to have one section for things that are moving and one section for things that are permanent so the moving section is in charge of the pieces obviously because the pieces are falling and they’re moving left and right And then the blue is in charge of well as soon as the piece hits the ground and becomes a permanent part of the screen we save it to this section because it’s not moving anymore so the way we actually move stuff physically is if you didn’t know you can use Locked repeaters which is a repeater powering another repeater in the side and you can de-power them for a small amount of time and it can shift the signal over so say that’s your piece and this is like your you know move left button and it moves The piece over so it’s the exact same mechanic for move left move right move down it’s all the same stuff and yeah so let’s say we we’re just starting a new game we spawn a new piece so it looks like that and that’s what the screen is showing me right now So the game starts it starts falling you know the drill it goes down like this all the way down until it hits the bottom now as soon as it hits the bottom the collision detection goes off and it tells it to save it to the screen So now we’re going to save whatever’s in here and just put it into here and then we’re going to clear it from this section because it’s not moving anymore so now we’re left with this we have nothing in the following section we have the board so far in our save Section and this is what the display shows so let’s spawn a new piece spawn a new piece like this and it displays on the screen it falls as normal and then it’s gonna hit this piece so as soon as it goes down here and hits that piece the collision detection goes off again And it becomes a permanent part of the screen so we get that signal and the signal says hey detection went off i need you to save whatever’s in the following section immediately to the save section and just clear the following section again so that’s the very basics of how it works And i showed you how the shifting works for the falling for the same section we just use a very small memory cell it’s just a torch going into another torch and you can shift between the two so basically if you hit this button it saves it right that’s something saved To the screen if you need to clear it when you’re starting a new game then you hit this button and it clears it so there’s one of these for every pixel so now let’s talk more about what actually happens inside the game so the first thing that Happens when you start a new game besides clearing the board from last time it spawns a random piece so the way we do randomness is with a hopper and a dropper and it’s got a sword in it and a redstone dust in it sword is like stackable or no swords not stackable or Whatever it it gives like a different signal strength output when you have a comparator next to it so when these droppers are powered it it gives a random 5050 sorter redstone into this hopper and then depending on which one it chooses this comparator either reaches this repeater with a signal strength of Two or it doesn’t with a signal strength of one um so after all three of these are powered we’re gonna get a three bit binary number either you know zero zero zero zero zero one and that binary number represents our piece we have seven different pieces You know zero zero zero through one one one i know that’s actually eight but i think one of the pieces is just doubled up anyways that binary number resembles our random piece and that’s where we get to these yellow lines here so i’m gonna generate a piece and you Can do that by hitting this button probably maybe yeah so we did get a random piece it came along on one of these yellows and each of these yellows is attached to a group of more lines and you can probably guess what that group is it’s all the different rotation states Of that piece right because we don’t just have one thing we need to display for each piece i mean for the square we do but for everybody else i mean the line has two different states the t’s got four different states this the l’s got four different states so Uh so what random piece did we get we got a z and if you look over here this giant thing is actually just the the memory bank that lets us you know choose what piece we want to show so we got a you know backwards z like to Call and you can see it right here it’s these lamps that are on so within its group it’s got two different states and if we hit that rotate button and i think you can just use this just to rotate it yep it switches over to the next variant Because it’s in this loop here and it’s just getting shifted over and it just loops around for as many times as you want to rotate so now if you look at what the memory is displaying it rotated the z i mean it didn’t actually rotate it just It just flipped to another line of rom but you know so if you rotate again it goes back to that first variant and yeah you get the idea so let’s clear it and spawn another piece clear and Spawn peace this time we got a t down okay these ones are cool so there’s our t just like before we can rotate it and it shifts into the next variant so yeah as soon as you’re happy with your piece you hit that drop piece button on the input And then your piece gets put into the falling section and this is the following section right here it’s this dark blue so the gray is responsible for shifting to the right i think the green is to the left and the brown is down so the way we do those three is just Like before i showed you with the repeater locking this pink just is usually locking this repeater and the output of it goes into the input of the guy to its left the guy to its right with this green and the guide down by one with this brown and now each of those Lines the green brown and gray are all being cancelled with a comparator right now none of them are being allowed through but depending on which way you want to shift left right or down that’s what you do you you unpower the comparators for whatever way you want to shift if You want to shift down you just unpower all of these comparators right here on these brown lines and then all of the signals will be sent down one layer so same exact thing on the left and right and yeah so once you’re happy with your piece and it starts falling we Immediately need to talk about collision detection because it could hit something right away you don’t know so you gotta have a collision detection built in everywhere and that’s what these lines are for so the red is the downward collision detection it’s detecting if there’s something directly under the piece at Any time or just for the left and yellows for the right so it’s really not that complicated it’s really just a giant and gate it’s literally just detecting hey are any of the pieces on our piece uh directly above something on the permanent part of the Screen and if so this line lights up and these are actually instant repeaters to be even faster and that’s so it powers it tells us this red line tells us when we hit something basically same thing with the orange and yellow so the orange is connected to all the ones to the left Of it so if if our piece at any time is right next to something on the left that’s on the permanent part then it’s just a giant and gate and this orange gets activated so then obviously the last part is the permanent part of the screen that’s the Second half with the light blue and you can see like i said it was like a torch into a torch right somewhere yeah right there so that’s what this is right here it’s a torch into a torch and that’s what this kind of memory cell thing Is for and then this light green is just taking all these and bringing them into the display so the next big part of this is the cyan wool it doesn’t look like a huge part of it but it’s responsible for all the line clearing and yeah it took a really long time to Kind of figure out how to do that just because i didn’t really know how like i just kind of had to think about it like for all the different cases right so when you when you clear a line and shift stuff down it seems simple but you have all these weird cases where Like sometimes you have a line on one and three and then in that case some things get shifted down by one and some things get shifted down by two depending on how high they are it’s like you have all these different cases and it’s just it’s just kind of crazy but The main thing i want to talk about is that um well there’s different ways to do it some are a lot more time consuming than others the quote easiest way to do it is to just manually check four times to see if there’s a line and if there’s a line clear it And move everything above it down by one and yeah you just you just do that four times and that’s what i did at first and then i realized that it’s really really really slow because you’re waiting as if there’s four lines every single time even if there’s not even if there’s zero It’ll still check four times and that’s just it just takes a lot of time like it works but i wanted something faster so what i did instead and i thought this was pretty smart is this first science file right here actually counts how many lines we have first and then Based on how many lines we have that are full then it decides what we need to do that way if we have zero lines which is you know most of the time we have zero lines uh it can detect that and it will know that we have zero lines and it’ll just Skip the entire line clearing process completely because we don’t have any lines so it just skips it if it counts one then it just clears the line once if it counts two three or four then it goes accordingly and that’s why these circuits here get longer and longer because these are the Different cases this is if we have one two three or four lines that we need to clear and the last major part of this is the brains of the tetris so this is called the sequencer this just kind of handles like everything at once i mean all these different lines are Different colors and they all resemble different things i actually have them all on signs right here so like you know the yellow would save the board to the memory so it would like take the falling stuff and move it into the save stuff you have all these different functions You need to do you need to add points clear the score spawn a piece rotate piece you know open up the moving section clear lines start the start the clock for falling there’s all these different things you need to be able to do so what i did is i lined up all the Things that we need to do and these are just all the functions of tetris and then i made a little chart for what needs to happen at each stage of the game so i have stage 0 stage 1 stage 2 and stage 3. stage 0 is when you first like press Start game and it just basically gets everything ready for you stage 1 is when the piece is at the top and it’s not moving but you can rotate it so these are just the two colors of things that we need to do during stage one and the way it translates over to this White thing is these four white lines are the stages zero one through three so as you can see right now this one’s depowered and this is actually stage one so stage one has certain torches attached to it and those torches are coded for the lines that we need So you can see up here stage one has green and light gray which translate to open up the moving section and show the piece rom so we have torches attached to the light gray and the green so that it does what it needs to do As soon as we drop that piece and it goes into stage two and it starts falling it does these three things one of them being the brown which starts the clock for falling so yeah i mean it’s this is the brains of tetris like i said it’s the sequencer it just handles out You know it gives all the jobs to everybody and it keeps the game going if you ever need to reset it like it makes it way easier because you can just reset it to stage zero and yeah so that’s how the sequencer works so yeah that’s pretty much it the only Thing i really need to say is that the scoring system was not made by me i did not make this at all this is all credit to mizuma games i think i’m saying that right he’s got this seven segment um switcher thing here it just works so well Like i honestly didn’t even make an attempt to understand this i just slapped it on here like amazing job to him i don’t even understand what’s going on here i mean i see comparators i see barrels with different amount of signal strength in them and yeah definitely solved him this is Really awesome but with that we’re pretty much done i’ve been talking for so long i’m literally about to lose my voice um i’ve had to record so much it’s really hard to like summarize all this down but try my best and uh if you got any more Questions of course you can just join my discord the world downloads in there too so have fun with that and hopefully you learned something thanks for watching Video Information
This video, titled ‘I Made Tetris with Minecraft Redstone!’, was uploaded by mattbatwings on 2021-06-28 19:00:12. It has garnered 348572 views and 19021 likes. The duration of the video is 00:17:15 or 1035 seconds.
This was my hardest project yet, arguably more complicated than a calculator. There is just so much going on behind the scenes.. line clearing, collision detection, scoring, rotation- but I got it done!
Patreon: https://www.patreon.com/mattbatwings Discord: https://discord.gg/V5KFaF63mV My socials: https://linktr.ee/mattbatwings World Download: (JAVA 1.16.5) https://www.planetminecraft.com/project/playable-redstone-tetris/
7-segment score counter made by @MaizumaGames
————————-
Want to get more involved in the logical redstone community? Learn Logical Redstone! https://youtube.com/playlist?list=PL5LiOvrbVo8keeEWRZVaHfprU4zQTCsV4 Open Redstone Engineers (ORE): https://openredstone.org/
0:00 Showcase 3:32 Explanation
Music (in order): C418 – Aria Math (Synthwave) [Remastered] – The Dominator https://youtu.be/yiS0DPekSDQ Tetris Theme — Xauric Remix https://youtu.be/Hsgvs1MgcQ4 Tobu – Seven https://www.youtube.com/tobuofficial