Placeholder Image

字幕列表 影片播放

由 AI 自動生成
  • 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.

    今天,我希望能回答你的這些問題,並帶你一起踏上用紅石製作 Flappy Bird 的旅程。

  • I hope you enjoy.

    希望你們喜歡。

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

    Flappy Bird》是一款由 Miniclip 製作的手機遊戲,最初於 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.

    不過,由於製作者認為這款遊戲太容易讓人上癮,它於 2014 年從 App Store 和 Google Play Store 下架。

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

    好吧,對不起,Miniclip,但今天我們要把你的遊戲攤開一點。

  • 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.

    好吧,我剛做了一個 16 盞燈乘 16 盞燈的。

  • 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.

    當我按下這個按鈕時,信號強度仍然是 15,然後開始衰減,但現在只有一個指示燈。

  • 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.

    我們在這裡做的是我喜歡的 "雙重反轉",反轉就是用 15 減去當前的信號強度。

  • 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.

    我們在這裡做一次,因為我們用 15 減去信號強度,這就是輸出,然後在這裡再做一次。15 減 7 等於 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.

    是以,如果將高度設為 3,那麼你只需抓取一個信號強度為 3 的桶,現在無論什麼信號強度進入這裡,它都會加上 3,然後從這裡出來。

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

    是以,在這個例子中,8 加 3 等於 11。

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

    如果我試試別的,比方說 10 加 3 等於 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.

    所以我們有 14 個。

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

    這將顯示第 14 盞燈。

  • 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.

    實際上,它給人的感覺已經像《Flappy Bird》了。

  • 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.

    舉例來說,我認為輸出是從這裡發出的,你可以看到它的單次強度為 7,這意味著它會像這樣上升並形成一個洞。

  • That's only seven long.

    這隻有 7 長。

  • 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.

    是以,這是一個 50 對 50 的隨機器。

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

    當我按下這個按鈕時,它要麼給我輸出,要麼不給我輸出,概率是 50 比 50。

  • 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.

    這樣它就會隨機生成一個三位二進制數,也就是 0 到 7 或 0、0、0 到 1、1、1、0、1、2、3、4、5、6、7 之間的隨機數。

  • 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.

    我們要做的就是使用解碼器將三位二進制數解碼為相應的 0 到 7 號火炬。

  • 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 門,每一行都有一個,用於比較管道和鳥。

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

    如果它們同時出現,它就會啟動,因為這就是 AND 門的作用。

  • Okay.

    好的

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

    我做了一堆 AND 門,然後把它們和這個塔一起訂購了。

  • 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.

    每當我需要這樣花哨的顯示器時,我就會去找我的朋友 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.

    這些計數器最酷的地方在於,當你像我一樣把它們疊在一起時,每當一個計數器從 9 變為 0,它左邊的那個計數器就會遞增 1,從而使這個計數器一直工作到 9999。

  • 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.

    是以,在這裡,當管道一直通到螢幕的盡頭時,我就會輸入這根線,這樣我們的分數就會增加 1。

  • 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.

大家好,歡迎再次觀看視頻。

字幕與單字
由 AI 自動生成

單字即點即查 點擊單字可以查詢單字解釋