Placeholder Image

Subtitles section Play video

  • Hi guys, welcome back to another video.

  • If you've seen some of my other videos, you'll know I like making games with redstone.

  • I really like making games with redstone.

  • But what goes on behind the scenes?

  • How do my projects get built from start to end?

  • Today, hopefully, I'm going to answer those questions and take you along with me on my journey to build Flappy Bird with just redstone.

  • I hope you enjoy.

  • Flappy Bird is a mobile game by Miniclip, originally released in 2013.

  • However, it was removed from the App Store and the Google Play Store in 2014 because the creator felt like it was too addictive.

  • Well, sorry Miniclip, but today we're going to be spreading your game a little bit.

  • First, let's think about the screen.

  • I think the best way to do the screen is with a lamp display.

  • I don't see any advantage to using pistons here.

  • As far as how big it's going to be, I'm not really sure, so I'm just going to make a starter screen and we can always change the size later.

  • Okay, I just made one that's 16 lamps by 16 lamps.

  • Now let's talk about the bird.

  • So, the bird is constantly falling.

  • To me, when I hear constantly falling, I think of a degrading circuit.

  • A degrading circuit would just lose value over time.

  • For example, you could have a comparator into another comparator like this.

  • If you imagine that this line right here is the height of the bird, if you start it like this, you can see how the height naturally falls down.

  • Here, let me put some lamps so you can see it a little bit better.

  • You start like this and see how the gravity part of the bird.

  • All right, so I played with the timings a little bit and as long as we're trying to make this game run in real time, I think this is probably a good speed.

  • Yeah, it feels about right.

  • The one problem with this though is that right now, aesthetically, the bird is just a huge bar of lamps that gets shorter.

  • I'd rather have it just be like the top of the bar, so a single pixel.

  • If we attach a red coder to this or a signal strength decoder, we can just get that top pixel.

  • I'll show you what I mean.

  • All right, I attached a red coder on the end of Now, if we send in a signal strength here, it's only going to light up one lamp associated with that signal strength.

  • When I press this button, it's still going to give a signal strength of 15 and start to degrade, but now it's just a single lamp.

  • Our lamp started up there and it falls all the way down to the bottom just like it had gravity.

  • All right, so we've got a bird on the ground.

  • We can set it up to the ceiling and then it'll fall down, but how do we make it jump?

  • Well, if we think about what a jump is, a jump is really just take the current height and add a value to it.

  • Why don't we just take this signal strength, which again represents the height, add some value to it, and then plug it back in whenever we want to jump.

  • It seems like it would work to me.

  • The way that we're going to add a value to the height is with a circuit like this.

  • This is the input signal strength right here, this is the output, and this is where you want to put the value that you want to add.

  • What we're doing here is what I like to call a double inversion, where an inversion is taking 15 minus your current signal strength.

  • We do it once right here because we're taking 15 minus whatever this signal strength is, and that's the output, and then we're doing it again over here. 15 minus 7 is 8.

  • If you don't do anything special to it in between the two inversions, then it's just kind of a comparator.

  • It goes in one signal strength, and it comes out the same signal strength, because inverting it once and then inverting it again puts it back to what it was.

  • But if we go over here and put some value here, that's going to subtract it from whatever it is in between the two inversions, and that actually adds it to the number.

  • If you want a proof of this, I'll put it on the screen right now, but yeah, I mean this is just the way I remember it.

  • The way to add to signal strength is just to subtract while it's inverted.

  • So if you jump height to be let's say 3, then you just grab a signal strength barrel with 3, and now whatever signal strength goes in here, it's going to add 3 to it and come out here.

  • So for this example, we have 8 plus 3 is 11.

  • If I try something else, let's say 10 plus 3 is 13.

  • So that seems to be working.

  • So now I just have to attach this to this, and we should have jumping.

  • Alright, I think it might be working.

  • Let's try to spawn a bird and jump.

  • Okay, maybe now it's working.

  • No, not at all.

  • Okay, finally seems to be working.

  • I changed some timings.

  • Alright, I think it's time to put this bad boy onto the screen.

  • To do that, I'm going to need a vertical red coder instead of a flat one like I have here, but I think I have a design for it.

  • Yep, I was right.

  • I have one in my schematics folder.

  • So this is a vertical red coder.

  • It does the exact same thing as the other one.

  • Whatever signal strength you put into the back here, it's just going to show whatever lamp that is.

  • So we've got 14.

  • That's going to show the 14th lamp.

  • Okay, I took the vertical red coder, I attached it to this guy, and I put it behind the screen.

  • I think it should work.

  • Let's try it out.

  • Nice.

  • It actually feels like Flappy Bird already.

  • The next step is to generate the pipes.

  • Since we have pipes coming from the top and the bottom, you might think it's easiest to just generate like a random length pipe right here, and then another random length pipe right here, and that would look something like this.

  • But I think a better way to generate them would be to generate one giant line and then pick a random hole, right?

  • Because once you have this line, if you just pick a random hole, like say you pick here, there you go.

  • Those are your two pipes.

  • To physically move the pipes across the screen, I think I'm just going to use a system like this.

  • It's actually pretty simple.

  • We just have an observer chain and then a bunch of observers coming off of that chain.

  • Whenever you give it an update, it gives you a nice three-wide pulse across these lamps.

  • Okay, I stacked it up a little bit and I simulated a little system to see what the pipes might look like.

  • Yeah.

  • I mean, that looks pretty good.

  • My only concern is that this might be a little bit too fast.

  • I mean, these are moving pretty fast across the screen and considering our bird only falls that fast, I don't think it'll mix well with those pipes.

  • But I mean, at the same time, you can also just make the bird fall a little bit faster by making this clock a little bit shorter.

  • So I'm not that concerned.

  • You know too fast.

  • This would, even if the bird was at the same pace and it was falling really fast, this, I don't think Flappy Bird is meant to be, meant to be this crazy.

  • At least not until you get to the later levels or whatever.

  • So I'm going to have to think of a different system to move the pipes across.

  • Okay.

  • I just had a thought.

  • What if we put repeaters on the back of these?

  • They're one wide.

  • So, oh, okay.

  • That's, that's much better.

  • Check it out.

  • Dude.

  • Oh my God.

  • I can't believe how easy that was to fix.

  • All right.

  • So like I said before, for each set of pipes, we're just going to create one long column and then generate a random hole.

  • To me, when I hear one long column and a random hole in it, that kind of reminds me of the vertical red coder again, because if you just invert this, now it looks like one long column with a hole in it.

  • So I think if I can find a way to modify this to make the hole bigger, that'll be perfect.

  • Okay.

  • I've been working on it a little bit.

  • I think I've got something promising.

  • So if we input a signal like that, we get a hole right here.

  • And if we input a different signal strength, maybe you want a little bit higher.

  • We get a hole that's higher up.

  • Okay.

  • That seems pretty cool.

  • All I did here was take the output from the red coder and make it go up a slab tower by a designated amount.

  • So for example, I think the output's coming from about right here and you can see it came out with a single strength of seven, meaning that it's going to go up like this and create a hole.

  • That's only seven long.

  • Everything else still has torches on it.

  • Okay.

  • I hooked up the fancy observer screen to it.

  • And now we'll actually be able to see the pipes right now.

  • It's set at this current height.

  • And if we press this button, it releases it.

  • And that's what the pipes look like.

  • That's actually pretty good.

  • We can go over here and we can change the height.

  • We can do something like this instead, press the button and we get a different height.

  • Awesome.

  • After playing with it for a while, I noticed that sometimes the holes are like too high and they chop off the top pipe.

  • So I modified the input system a little bit.

  • And you go right here and press the button.

  • That is the highest possible hole.

  • Or if you go right here and press the button again, that's going to be the lowest possible hole.

  • And that means that this redstone line is essentially our range.

  • So now we just need a way to randomly assign a random piece of dust to full power.

  • The easiest way to do that is with a randomizer circuit.

  • So this is a 50, 50 randomizer.

  • When I press this button, it's either going to give me an output or it's not, it's a 50, 50 chance.

  • The way this works is we have a dropper pointing up into a hopper and the one non stackable and one stackable.

  • If it chooses the non stackable, which is the ax, it's going to output two signal strength and reach the lamp.

  • But if it outputs the stackable, which is the dust, it's only going to output a one signal strength, which does not reach the lamp.

  • So let's activate three of these at once.

  • And that way it's going to generate a random three bit binary number, which means it's going to be a random number in the range zero to seven or zero, zero, zero to one, one, one, zero, one, two, three, four, five, six, seven.

  • Can you see where I'm going with this?

  • All we have to do is use a decoder to decode the three bit binary number into its corresponding torch zero through seven.

  • And now with three randomizers and a decoder, we can choose a random torch every time we press this button.

  • Okay.

  • I made a little circuit to automate it and check it out.

  • Random pipes.

  • Let's put this thing on the clock.

  • Oh yeah.

  • That is amazing.

  • All right.

  • We've got pipes.

  • We've got a bird.

  • Let's try to combine them.

  • Okay.

  • Slight problem.

  • And I probably should have seen this one coming, but the observers don't mix very well with the red code or like, I can't bring these observers across here, which means that the pipes just kind of disappear as soon as they reach the birds column.

  • I'm sure there's a way around this though.

  • I might have to redesign something, but I'll let you know what I figure out.

  • Okay.

  • I'm convinced there's no way to pass this bird straight through the observers.

  • So what I did is I made the observers go across the entire screen and then we can just put the bird on the end here.

  • That way these observers can get the last pixel.

  • And now the bird's actually going to look like it's going through the pipes.

  • And there we go.

  • The bird's actually going through the pipes.

  • I'd say this is our first prototype.

  • It does kind of suck that the bird has to be on the very edge of the screen, but it keeps the hardware nice and simple.

  • So I'm all right with it.

  • The next thing I want to do is I want to change this input system.

  • I don't want the person to have to press a button and then look back at the screen.

  • That's kind of awkward.

  • I would rather use something like a tripwire.

  • That way the player can actually jump.

  • Okay.

  • After messing with tripwires for way too long, I finally found a nice system.

  • All you do to use it is stand on the trap doors.

  • And whenever you jump up, your head hits the tripwire and that makes you jump.

  • And it even works if you hold down the space bar, which is really nice.

  • Okay.

  • We're really getting there.

  • I can turn on the pipes with this lever.

  • And as soon as you start generating, now I can just stand here and jump with the bird.

  • The last thing we need is some collision detection because right now, if the bird hits the pipe, absolutely nothing happens.

  • So we need to check if the bird, which comes along here and the pipe, which comes along here, hit each other, which means they both occupy the same block at the same time.

  • The way to do that is to make a bunch of AND gates, one for every single row that compares the pipe and the bird.

  • And it'll go off if they're both there at the same time, because that's what an AND gate does.

  • Okay.

  • I made a bunch of AND gates and I ordered them all together with this tower here.

  • So if a collision happens at any row, it's going to hit one of these dusts and go up the tower and let us know on this main line.

  • And this line is our collision detection line.

  • By the way, I moved the tripwire circuit out a little bit, just so that it's easier to use, easier to see the board.

  • So right now the lamp is always off, even if we jump, because there's no pipes.

  • So there's no way we could have a collision, but I'll purposely die here and we can see as soon as we hit the pipe, lamp goes off.

  • Hit the pipe again, lamp goes off.

  • Seems like it's working.

  • I think it's time to set up the control logic.

  • Control logic is what manages the game.

  • Right now the game just runs nonstop.

  • It still needs a process to kind of help it organize its tasks.

  • Okay.

  • I built up a little schematic.

  • I think I want to do something like this.

  • The game is going to have two different states, a default state and a playing state.

  • It can only be in one of these states at a time.

  • When you first download the world, it's going to be in the default state.

  • So in the default state, there's going to be no pipes.

  • It's just kind of sitting there waiting to be played.

  • Then when the user presses the start button, it puts the game into a playing state.

  • When the game gets put into the playing state, it has to do these two things.

  • It has to start generating the pipes and it has to add one score every time we get through a pipe.

  • Yeah, sorry.

  • I forgot to mention, I want to do a scoring system as well.

  • Okay.

  • So all is well, we're playing the game, but then if a collision is detected, AKA the bird hits a pipe, this goes off and puts the game back into the default state.

  • Now that we're in the default state, we need to stop generating the pipes and we need to clear the score.

  • And that's about it.

  • That's all the control logic we need.

  • I'll be back when this is put into the game.

  • Okay.

  • Finished most of the control logic.

  • I put a start button right here and it goes into the latch that toggles between the two different states.

  • It's the exact same latch that I had in the schematic over here.

  • When we press start game, it toggles into the playing state and the playing state is directly hooked up to the generating pipes.

  • So now as we're in the playing state, the pipes are on the screen.

  • Then I took the collision detection line and ran it all the way back to put it back into the default state.

  • And finally, I put up a display counter.

  • Whenever I need fancy displays like this, I just go to my boy Mizuma Games.

  • He has incredible designs.

  • This is the one we're using right here.

  • So every time you update this observer, it counts up by one.

  • And what's really cool about these is when you stack them next to each other, like I have, whenever one goes from nine to zero, it increments the one to its left by one, making this a fully working counter all the way up to 9,999.

  • So right here, when a pipe gets all the way to the end of the screen, I put in this wire, which increments our score by one.

  • And that is about it.

  • I'd say that we have a working Flappy Bird game.

  • Now that everything is working, I'm going to do a few final things before I'm finished.

  • I'm going to redo the layout so that more of the stuff goes behind the screen instead of off to the side like this.

  • I'm probably going to give it a little bit more decoration, and I'm going to test it.

  • A lot.

  • It's always good to test your game when you finish.

  • Other than that, I'll see you in the showcase.

  • So make sure to subscribe if you enjoyed this video and want more of them.

  • Thank you for watching.

  • I hope you learned something.

  • I hope you enjoyed.

  • Peace out, guys.

Hi guys, welcome back to another video.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it