Placeholder Image

字幕表 動画を再生する

  • Hello.

  • A little out of sequence video.

  • I was challenged on my discord server to code the game break out in 30 minutes, and I was to do it live in front of an audience.

  • I'm not gonna get into the habit of loading my life streams, but I thought this one had enough educational content that it should be going on main YouTube channel.

  • Anyway, this is how we got on Enjoy S o.

  • The title of the stream is the sign Hunters challenging Assigned Hunter is a member off the discord community who had the idea that maybe I should have a go at trying to program break out as fast as possible.

  • Originally was 20 minutes.

  • We negotiated toe half on hour.

  • I think it's probably gonna be more like 45 minutes, but it might serve as a useful video for people who haven't used the console game engine for anything on Dhe.

  • They can look at this and see how something is done from scratch.

  • I'm not saying we'll get it all right.

  • And perfect.

  • First time.

  • I also don't think it'll look very pretty, but we can see how we get off of the audio levels.

  • Okay, can somebody give us a shout?

  • So let's have a go.

  • I'm going to start a timer just because it's fun to start the timer, but I don't think I'll be able to do it in half an hour.

  • But we'll see.

  • I think we'll only get it something, something doing within an hour, anyway.

  • So let's have a go, right?

  • Good time is ticking over.

  • So the first thing we want to do is actually include the console game engine.

  • And then we want Thio overwrite the class that it provides, so we'll have to do that ourselves.

  • So we'll call this one a recount.

  • We'll see Consul Game Engine.

  • And so the point is that the council damage and provides two functions in the background, which the operator or the user will need to override to facilitate gameplay.

  • Well, just stick in a constructor.

  • Remember, I'm on the clock, so I'm not going to be describing everything into much detail.

  • You'd usually stick your name in the Let's Do the two overridden functions avoid on.

  • It's not Boyd is.

  • It's bull on user creates, which is where we'll create all of our static resources of course, I probably won't be able.

  • Thio, read the Read the chapter whilst I'm doing this.

  • I'm not gonna be pausing the timer, um, on on user dates and that passes in f elapsed time, which is what we're using to keep everything in sync.

  • What's he got to class?

  • We then need to create our main function.

  • You gonna be my typing that's gonna let me down with this on.

  • We want to create an instance of our class.

  • In this case, it's a great count game.

  • Once we've got that, we want to create the console with the construct Consul function.

  • Until that we pass in the resolution, which we're going to draw things out now because I've been using it a bit recently.

  • I'm going to use to 56 by 2 40 by four by four.

  • So that's the width and height in characters on the size of the character is going to be four by four pixels.

  • I'm going to assume that that's going to work so we'll just call the start function straight away.

  • Let's have a look.

  • Not gonna work straight away, not returned tree from that.

  • So if you return true, it doesn't cause the game engine to stop.

  • If any of these functions return false, it will automatically cause the game engine to stop and clean up.

  • So there we go.

  • We got a window running at a number of France for second.

  • Good.

  • Don't read code.

  • We're the splits.

  • Yeah, I should have just splits, but I need some more splits to work against anyway.

  • Right?

  • So how are we going to structure this?

  • Not even thought of any of this.

  • So we're going to need a level that represents the blocks.

  • I'm going to stick with the old Jerry A way of doing this.

  • I'm going to create a string todo Let's define what we're going to have as a level.

  • I think level's gonna need a width and height as well.

  • How wide is an ark annoyed level?

  • I have no idea.

  • I'm going to pick 16 pixels.

  • What's 2256 divided by 16.

  • 16.

  • So we get up sort of half the screen with blocks, maybe something like that.

  • Okay.

  • Point on the hike would be 16 blocks to 40.

  • Tango on a second.

  • That's 15 pie.

  • That's going to be the full playing field 16 15 draw that recall it would hold it level right?

  • So, to the level I want to dio Want to make sure you count this out properly.

  • 123456789 10 11 12 13 14 15 16.

  • But right, let's put in some blocks then, um, so we're going to use the fir boundary blocks.

  • I think we'll use the hash symbol, so let's just get it to draw the level to begin with.

  • Firstly, will probably want to erase whatever this.

  • I'm going to cheat a little bit by using the space character to do that.

  • So let's draw the level.

  • Let's assume a block is eight by eight grid with Yeah, I know So So I'm going to do two nested four loops and we're going to draw the contents of the level to the screen So way.

  • Want a switch block for the level at that position level?

  • Why times and with plus six case, What did we have?

  • So if it's a hash that's going to be our boundary, it's Phil Recht.

  • Uh, next time's and block coma White times and block Common X plus one times and block comma y plus one signs and block and on what color were going to do.

  • We want that to be a full solid pixel on.

  • We'll set that thio g white.

  • So the boundary off the level is going to be white.

  • Lots of little red squiggles there.

  • Why is that?

  • Oh, it's not Phil Rector's.

  • It is, uh, just felt.

  • So it's found a Windows commander.

  • Oh, yeah, Phil, that's for a regular block.

  • Was couldn't paste that on for empty space, which I'm gonna use the period symbol for will draw that as block quick.

  • Look.

  • Okay, it's a little bit smaller than I thought it was gonna be, But maybe this is a scale to work, and we can play the numbers later.

  • So let's just put in some other types of blocking here.

  • Insert.

  • We'll use the numbers one to represent a block.

  • I don't know.

  • Maybe later on, I'm not.

  • Maybe not for this challenge, but if we choose different numbers, perhaps that's how many times you have to hit them before they disappear.

  • But let's let's just fill that in for completeness.

  • We also want it's a one c.

  • You do use the insert k.

  • All those GS code people that don't have it.

  • We'll set the cool of the block to bay.

  • Agree?

  • Okay, so it's now draw in a bat on, add some user control.

  • Tow it.

  • We'll try and work in the floating point.

  • The main mats as the bats only really got one position, hasn't it?

  • It's just going to be bat, I suppose, on.

  • We'll set that to the middle off the playing field, which is going to be, Ah, something like 64.

  • We'll see.

  • Um, let's draw that into so for the bat will just draw in a line for the bat with.

  • You might want to play with that with late if we're gonna add power ups and things, but we'll see.

  • Let's step back to being 10 either side of the center point.

  • That might become important.

  • So its drawbacks droll line take, and that's where we're going to draw it.

  • Well, it's going to be and height minus a little bit and heights on block minus two.

  • Uh, but plus and back Wythe, we'll draw that as pixel solid on again.

  • We'll draw that white.

  • We'll just keep that one appear that looks like it might be quite useful.

  • Let's just see if that's drawing a fact throwing anything.

  • I hope I did draw something too long to start.

  • There we go.

  • Okay, We've got a bit of a bath.

  • Let's sound some controls for the bats.

  • Now s So we're going to use the get key.

  • Will use the left and right arrows.

  • It's only if it's held down.

  • Do we want to do anything that the left yourself down?

  • Now we want to deck Ament the fat.

  • I don't know what speed is going to be yet, but we'll see you choose a number the last time on if we want the right key.

  • We want to do the opposite now with no pony constraints on the back yet.

  • So it's going to drift all over the place.

  • So left and right, k.

  • Well, too slow.

  • Way too slow.

  • Changed.

  • I think it's going up.

  • Helps you impressing the right keys, doesn't it?

  • That's probably still too slow.

  • Double what?

  • Speed?

  • OK, so we put a bat in right now, it's time to add a ball.

  • We'll just start the ball somewhere in the middle is well, I don't know how far down is gonna be, but we'll probably be somewhere about right.

  • We'll also need a direction that the ball is traveling in Rome.

  • We now should I use it using an angle or sledges to with Delta's?

  • I'm just going to do with Delta's uh, Bolty X will just start that office.

  • We'll have to actually, we'll have to calculate that from an angle, sir.

  • X and one.

  • Let's do that here with a bit of code.

  • I want to pick a random angle for it to start with.

  • Yeah, runs divided by closing point.

  • Random number, please.

  • Giving me 01 times it was two pies.

  • Yes, 20.14159 times.

  • That's good.

  • So we'll set our four DX.

  • Because this way, I know I'm going to get a unit vector for the speed of the booth.

  • Okay, so we've got a full We need to draw the ball way.

  • Do fur ball to actually use a circle.

  • Yeah, Why?

  • No Bill circle Now I'm going to cheat a little bit.

  • Even I'm going to set the balls radius to be something like two or three.

  • I think for the collision, I'm just going to keep it as a single unit.

  • A single pixel ball has left a fact about with the collision of the wife S.

  • O F ball, except for why Radius I said that to get just two pixels ball is going to be a solid again yellow.

  • Let's just say that just indeed.

  • Drawer fall.

  • Yep, Right.

  • So now we want to update the physics off the ball and we'll do that after we moved the bat to give the players chance.

  • So this is where it gets a bit tricky and fun.

  • Now let's have a look.

  • So the ball needs to have its position updated so full X plus equals, you know I'm going to do.

  • Actually, I'm going to maintain a cache of where the ball waas.

  • I think that's probably how I'm going to solve the collision detection.

  • Let's see.

  • Bull X plus equals ball.

  • The X on times the last time, times some speed.

  • We don't know what it is yet.

  • We won't do the same for why just stick that a beer in a temporary constant area B equals 20.

  • Let's just have a feel for how fast that is really slow.

  • Also, disappointingly, it's also just sort of gone straight.

  • Why's that?

  • What was going on?

  • So the ex is that Dean Wide Little Tiny number?

  • Maybe it's just unfortunate coincidence.

  • That's how it started off.

  • I'll tell you what, we'll make it bean random to begin with, we'll just have it.

  • No 0.6.

  • Okay, good.

  • So let's get a bounce off solid objects.

  • To do that.

  • I want to work out where abouts in my array.

  • I am So that is simply and sell X equal value are all ex mines.

  • No, it's not.

  • Not minus divided by something similar for why, Okay, I'm also going to get so new necks.

  • We'll do something similar to this old ex using the older variables on.

  • The reason I'm doing this is because I'm going to make a check on the weather Collision has occurred by looking at Watts the ball in an empty cell before it was in on occupy itself.

  • Because that way I can also work out to make it right.

  • I can work out which direction I've hit the cell from which army to doing also deflect the ball appropriately.

  • So let's just see what happened with new cell.

  • So actually grabbed the contents of the cells.

  • Thio char New cell equals level.

  • New cell Why?

  • Times And with new cell x No time for these to the amateur time wasting mistakes on.

  • Of course, that's not new, is it?

  • That's actually old.

  • And that one's old on that one.

  • Old right?

  • Got there in yet.

  • So if news cell equals, let's just do it, do it.

  • Let's just test to see if we get the collision so that working first, if New Cell is a solid wall, as in it's the boundary, then we need to work out which direction have we hit from?

  • So I can do that by saying, If on new called these new cells in a cell, new X is greater than And so I knew why old ex that way.

  • I hit the coming from the left, so that's a collision in the left axis.

  • So I want to invert in that situation.

  • Let's just see what happens that so the ball's coming along.

  • There we go.

  • So it bounced off the wall.

  • Okay, it's gone after pounds.

  • We'll worry about that in a minute.

  • Well, just speed the ball up.

  • Might move.

  • Make it move a little bit quicker.

  • Let's do something similar for why I think just to test all of this out on going to put in an artificial floor for now, I don't think I'm going in the right direction with this, We'll see.

  • Yeah, okay.

  • It's that drifts off into the middle of nowhere and, you know, with some sort of circular logic here, that's not gonna make any sense.

  • Corners.

  • Okay, so that's a bowl bouncing around.

  • Good.

  • Good.

  • What we shall also do is in the event off.

  • It's not being not being a full stops of empty space.

  • New cell, our one brute force.

  • Poppy, you if it's a number, I'm just going to set the number two being space.

  • Okay, Okay, okay.

  • Hits anything.

  • It's going to inverse its direction.

  • If it hits a number, it's going to change that to a space and still inverted direction.

  • Look at that.

  • Okay.

  • All right.

  • So now we want to worry about the bat.

  • Uh, so we know a little bit of a check in the bat if the ball is greater than where did we petition the bat?

  • But I put it on height claims to minus Ah, if Theo the F four y is greater than that position vertically, then we want to check.

  • Is it within the bounds?

  • Off the bat?

  • Full access.

  • Great Savannah back minus and wit on Ball X is less than plus, and that's wits, sticks and brackets in there not to tempt fate.

  • Want to bully?

  • It'll tell me, uh, if it's s So we've hit the bats.

  • We want to invert the y Axis else dead.

  • Which point we'll look choose Will sent the ball to Bay Bull X equals on with divided by two times on block.

  • We'll set the why to be somewhere also in the middle.

  • Wilson and the two randomly choose an angle again.

  • We'll take all of that, right?

  • So let's just remove this wall.

  • Okay, bounced off the bat.

  • Come on, ball faster.

  • Let's just try and die and see what happens.

  • Okay, so the ball gets respond somewhere on the game.

  • Continues way.

  • Want the ball to just be a little bit quicker.

  • It's a really good songs that have been back around when this is play s so we just want to constrain the fat.

  • Now don't wait.

  • It's not here So the bats, Linus and wit?

  • No, that's not shape.

  • Yeah.

  • Yes, it is.

  • Is greater than is less than on block way.

  • Want to set that fat equals n block Plus on back with on for the other side, If that's a plus.

  • And bat wits is greater than and with a Glock equals with finest.

  • And so forget about trying to stop the ball.

  • It's just make sure the battles we get semi colons, semi colons.

  • Okay, kind of gets on that side.

  • Stop solid on that.

  • So?

  • So it's there with take one.

  • So knowing that let's just stick in a few more blocks for an interesting shape in the This one is great.

  • Block.

  • Come on.

  • Don't let me down now.

  • How are we doing?

  • Almost a big crash.

  • Why's it going through the back?

  • Well, I think with your acceptance is that good enough for break out in half an hour?

  • Can I stop the timer?

  • I think that's not bad.

  • I mean, we could have had more bells and whistles to it.

  • There we go.

  • 29 26 75.

  • There we go.

  • Well, never been so nervous in my life.

  • Yeah.

  • So what I need is a team, uh, is that the writer think their way.

Hello.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

A2 初級

30分でコード・イット・ユアセルフのブレイクアウト? (Code-It-Yourself Breakout in 30 minutes?)

  • 21 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語