Breakthrough (DnD Tutorial Part 1/2) - GameMaker Studio 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there I'm friendly cosmonaut and we are going to be making breakthrough now this tutorial is aimed at beginners so if you're new to programming OTO game maker you should be totally fine so this tutorial is going to teach you to make a game but more than that I want this to be an example of how to approach making a game from scratch so what your workflow might actually look like and how you might solve problems as they arise and we'll be doing this over a two part series if you haven't already let's load up game maker you might already be familiar with the start page but this is where we can go to launch our projects and also explore some resources such as the marketplace tutorials and demos so we're going to go ahead and make a new project and now we have two options so we can make a game in drag-and-drop or game make a language and this will just change how we go about programming ok so if we use game maker language or GML then we're going to be using actual code to make our games and if we use drag-and-drop then we'll be using a visual scripting language and constructing our programming logic out of action blocks all right so we're gonna go ahead and hit drag-and-drop and I'm gonna call this breakthrough D&D tutorial and we'll hit enter and load the project up so here we are in a fresh new project and I'm going to just spend a couple of minutes taking you through this interface if you're not familiar with it so right here in the center is the workspace and this is where we're going to be doing all about work all the editors are going to be popping up here and we can actually add more workspaces by clicking the little plus up here and this can be really handy for example if you're working with two monitors and you can drag this to the other monitor or if you just want to have two tabs open and we can talk about here we can also mess around with this layout a little bit so for example down here there are some docked panels and we can grab any of these and move them around the project including this one here and at any point if you've messed around too much and you want to restore back to the default then we can just come over to layouts and reset the layout now most of the tabs down here we're probably not going to be looking at just as we're starting out probably with the exception of this output panel because we'll see this popping up when we run our game for testing and this is just where we can see the game compiling and if there's any compiling errors they'll pop up here but that's fine for now so we can close this by clicking here or we can just hit f12 and that will dock all this halves now up here I do just want to point a few things out so in the file menu it has pretty much what you'd expect but there's also an option here to open up an entirely new IDE so if you want to have two projects running at once and in the preferences right here there's a lot of things that you can tweak from the actual appearance of the IDE to some important settings so in the general settings we can set the skin the language we can change the color of things like this resource tree right here so for example we can change the color and fonts and of course at any time you can restore back to default so you might want to spend some time just messing around with there to customize your workplace all right now up here are some quick buttons that will take you to particular menus and you can just hover over them to see what they do so we can go back to the start page here open new projects and save them and one of the most important ones is this play button right here because this will actually run the game and you can see you can also just hit f5 to do the same thing so if we click that it should build our game but of course we're just giving this black window because we haven't actually put anything into the game so it's entirely blank if we press the stop button up here it's gonna stop the game from running this little debug one is going to run the game as well but it's going to run it in debug mode and the debugger is a tool that we can use to profile our game and to check for performance and also help us debug and again that's probably not something we're going to be doing in this tutorial but you might want to look into it later now finally over here we have our resources tree and I'm just gonna slide this up here so that we can view it a little bit more easily and this is the heart of our project so anything that we use or create is going to be stored here in different sections so the main ones that we're going to be using are the sprites objects rooms and also sounds and fonts so let's start with sprites you can think of sprites as the containers for any image that we're going to be using in the game so all of our objects like the bat the ball the backgrounds they're going to be represented as a sprite in our project so we can import sprites or you can actually use the inbuilt sprite editor to create the sprites yourself so let's make our first sprite let's make a brick so I'm going to right click on sprites and create a new sprite and now it's gonna prompt us to name it so I'm just gonna call it brick for now and I'm just going to dock those panels I can move around the workspace by middle clicking and dragging my mouse and I'll just make this a little bit larger and right here you can see the image as well as a few options over here so one of the most important ones is this one right here because this will actually resize the sprite so let's click this and for the brick I want this to be kind of rectangular-shaped so I'm gonna change this from 32 height down to 16 and it'll hit apply so there we go it's resized and I'm just gonna hit control and scroll to zoom in and that's my image right now and to actually bring up the sprite editor to create the image we can double click on here or hit edit image all right and now I'm just gonna draw a really basic brick so I'm gonna use this rectangle tool right here and I'll use the black color which is right here on the right mouse-click and I'm just gonna draw a square and I'm gonna color the brick in white because we're actually going to be coloring the bricks using our programming logic a little bit later but for now it's just going to be a white brick all right so let's exit out of that so you can see there is our image I'm going to just leave everything else at the default and now if we're bringing out the resources trade then I'm going to create an object for this sprite because at the moment a sprite is just an image it can't actually do anything on its own but we can attach it to an object to get it to appear in the game so objects are where we put all of the game logic they will be in charge of doing absolutely everything to make the game work and they're going to be doing this ply performing the instructions that we tell them with our programming logic so every single thing in the game is going to happen because of something that we put in an object and essentially all the different programming logic that we use is going to boil down to telling the objects if this then that so if a certain event happens do a certain action and of course we can create layers and layers of this kind of logic to create complex behavior so let's go ahead and create an object so right click hit create objects and again it's prompting us to name it so let's call this break again but when we hit enter as you can see an error has popped up telling us that this is an invalid name because if we have already used the name brick and names for our resources must be unique so this is an important point to remember you can't call your resources the same thing and that's why the convention here is to actually use a prefix so for the sprite I'm going to edit its name by either pressing f2 or right clicking and hitting rename and I'm gonna call this SPR brick and then for the objects I'm gonna call this obj brick so now not only does this allow us to kind of call both of these break but we also know what the resource is by its prefix so this is a sprite and this is an object all right now let's move on to rooms so if I just click this right here we can see that by default game maker has already created a room so room 0 and we'll use this for now but I might just rename this to continue with our naming convention so I'll call this RM game and let's double click on this to bring up the room editor so a room is kind of like our game wild or more specifically a game level because you can have multiple rooms in your game and switch between them only one room will be running at a time and if an object like our obj break which is in the resources panel if it isn't in the game room that's running then that object doesn't exist functionally in the game so think of objects kind of like how they exist in your mind just like the idea of a dog you know that the object dog has certain properties it has fur a tail four legs it performs certain behaviors it wags its tail and fetches balls but that doesn't mean a dog object has to exist in the world just because it's in your head so for example you also have an idea of what Unicorn is its properties and behaviors but we know that unicorns don't exist because there aren't any instances of them in the world so in the same way to make an object exist in the game world we need to create an instance of it and that's what dragging and objects into the room does and we can even create multiple instances of the brick and we can also give these individual instances different properties just like how different instances of dogs can have different properties in our world different colors sizes and breeds and so on and we can do this here by for example double-clicking on one of these instances and tweaking their variables and creation cards now before I explain anything else about the room let's just run it so let's hit f5 or come up and hit the play button and as you can see we still just get a black window just as before so we did create our objects they are there in the room but we just can't see anything and that's because we didn't actually tell them to draw anything so let's quit that and come back to our workspace I'm gonna quit this room editor and now you know brick object we are going to assign a sprite so right here it says no sprite we're gonna click on this and we're gonna select that sprite that we made so now if we come back to the room you can see that our bricks see here but as you can see they're actually quite small in the room so I'm going to change the dimensions of this room so let's explore this side of the room a deter a little bit up the top here are the different lays in the room and at the moment we just have to sew a background layer right here and an instances layer and we can toggle their visibility like this the instances are where we place the instances and you'll notice for example that if I select the background and try and drag in a brick it's not going to work because we can only drag instances into an instance layer and there are a few other types of layers too for specific types of resources so we can create another background in instances there but there's also tiles paths assets and even folders that we can use to organize a layers and you can do different things in all of these layers so we can see in this one right here all of the different instances that are in this layer and in the background one we can change things about the backgrounds so for example we can show a different color in this layer we can even show a sprite and tile it or even stretch it but I'm gonna leave this at the default for now so I'm just gonna put that back to none and I'll keep the background at black but feel free to have a play with some of this if you want now down the very bottom here this is the room settings so this is where we can set the width and height of the room and I'm gonna change this to 640 by 480 so that seems like a pretty good size for our game and I might just move these bricks a little bit so so I'll go back to the instances there and I'll hit control and select all of them and I can move them around now all right so now let me run the game we should see that the window should have changed size and we can see our bricks now okay now that we've had a little look around game maker we should move on to actually making the game so where should we start so a lot of the time developing a game is all about breaking down big tasks into incremental small ones so let's practice how we're going to approach this so we know our game is going to be about using a bat to hit a ball into these bricks and if we miss the ball and it hits the bottom edge we lose and if we get rid of all the bricks we win so those are the main mechanics and objects that we need in our game so to start off with how about we just get them showing up in the room so let's make a few more sprites and objects so first off for the sprites let's make the ball so svr ball and I'm going to make this a little bit smaller than the brick so let's change the size again and I'm going to put this down to 16 by 16 and we'll double-click right here and I'm gonna use a circle tool now just to make the outline and I might just color this yellow all right so that's our bowl and now let's make the bat it's a SPI bat and this is going to be what the player is controlling to hit the hole with so I'm gonna make this a bit bigger than the brick a bit wider so I'm going to change 32 to 64 and I'll thin it out a bit and have it as 16 for the height and let's come in here and exactly's before although I'll use a byte order this time and I'll make it look a little bit rounder by getting rid of the corners and we'll just color it a nice screen all right so now let's make those objects for the bowl and the bat to right-click create object obj bat and I'm gonna assign this to the bat sprite and the same of the bowl all right so now we can come back to our room and we can go about placing these objects in here so we can crag them in just like this and also Apple and now let's add in a few more bricks except first off I'm just going to change the dimensions of this grid up here so I'm gonna click this little drop down and because our bricks are 16 by 16 I might just change this right here and just note that you can also untick snapping if you want to place those instances precisely I might leave it on and one thing I just want to point out is the anchor for the objects so if we double click on one of these instances take note of its X&Y position because if you move it up to the top right here you can see that it says it is now at 0 0 and that's because it's anchor is at the top left of the sprite it's not down here and if we move it around the room we can see that its position is changing and if we come back to the spice we can actually change its origin so this right here is its origin and we can just click any way we want on the sprite to move it manually but we can also set it to a preset right here so for example let's just set everything to the mill center so I'm going to do that on my Bowl as well and the bat and now when we come back to the room you can see our instances have kind of moved over a little bit and that's because its origin has changed so it's still at error zero but it's anchor is just in the middle now all right now let's drag in a few more bricks but instead of just dragging them in one by one what we can do is just select the brick hold alt and then we can kind of paint them on all right so now if you run the game we can see that all of our objects are showing up and at this point we remember that all of our bricks are white we actually wanted different colored bricks to be appearing and like I said we're actually going to do this with our programming so I'm going to quit the room editor and we're going to do our first bit of programming sir we're actually going to tint this sprite it's be any number of a few random colors so some pink some green whatever and I want the bricks to do this as soon as they're created I want them to pick a color for themselves so remember how I said that basically old programming logic kind of comes down to if this then that so what we want to say is if the object is created or when it's created then change its color so we can do that by coming to the brick and adding an event so if we click this right here and you can see all the different types of events right here when it's created when it gets destroyed when a frame is run or a step when a key is pressed but for now we want this one right here so create and in here we can use these action blocks to construct the logic of our programming so in here I want to change the tint of this brick and you can see over here are our different action blocks and as well as the different headers and sections we can actually use the search box right here to search for what we want and I'm going to type in instance because we are going to be changing a variable that all instances have and there is a set of these called instance variables such as the X&Y position of instances so this one right here the set instance variable block right here in the drop-down we can select the instance variable that we want to change so you can see there's quite a lot of them here and I actually highly encourage you to have a read of what these do by looking in the documentation I really had anything to do is any of these action blocks if you want to find out more about them you can right-click on this go to show help and the documentation page should open for that action block so here you go you can read all about these ones but the one that we're going to use this time is called instance blend so the color to be blended with the instance sprite at the moment you can see it's just white we're going to change that so let's set that as the variable that we want to change so image blend color and now here we're going to put a new value for it but I don't want to just set it to one color I want to set it to randomly select from a range of colors so we're going to use a different action block and if I just type in random you can see that here are a few random functions and this one right here called choose is the one that we're going to one so it randomly chooses of the selected arguments that you give it and if we click on this little plus right here we can add new arguments so now we can put in all of our different colors and now I'm going to use the color constants so you can use these by typing C underscore and then any of these colors so I might go red blue yellow green fuchsia and orange alright so those are all of the colors that we can choose from now this function also has a target right here and this is if you actually want to save the value that it chooses which we do of course because then we need to reference it here so we're going to save what this function returns so it's going to return one of these six options into a variable called color so that now I can put this right here and it will set the image of Len color to whatever it chooses here now the very last thing there is a temporary tick right here this is if we don't need to save that variable basically as soon as this frame gets performed as soon as the create event is over it can be discarded from memory if it's a temporary variable which is what we can do because we don't need to remember the color past that point we only needed it for this one frame so that we could reference it here so now if we test that we should get all of our bright colors so there we go every single brick has performed this logic right here and chosen the color for itself all right so obviously although the game is set up we still can't move the player so let's get the player moving so let's quit that and come over to the bat alright so now I want to get it to move in response to our input so remember that the bat can move to the left and to the right and I'll get it to do that when we press the arrow keys so I'm gonna go at event and then key down and you can see there's a few different key event so for example key pressed that is only going to happen on the one frame we go from not pressing the key to having pressed it and that's not what we want we want to move every single time so long as the keys down so we'll go four key down and we'll do left first so in the event that we have pressed the left key down then I want to move the bat so we can do this by changing the x position of the bat so if you move it to the left remember that the X origin for game maker the zero for an X it starts over on the very left of the screen so if you were say in the center of the room at something like 200 and you wanted to move it to the left towards zero then we'll be decreasing X so if you're just typing a movement you can see all of the different kind of movement action blocks and you can have a read of all of these but there's a few different ways to get an object to move but since this is quite simple movement I'm just going to use jump to point because this lets us just manipulate be x and y so like I said we want to be decreasing but I don't want to just put in a number here say 7 because that will just make it snap immediately 2 7 so we want to do is have it moving a certain amount relative to what it currently is and we want to be subtracting minus 7 and we'll do the same for keydown right jump to point it should be in this recently used tab right here drag that in and we'll use 7 as well and take relative so if you've run the game now then we should be able to move that bat to the left and right so there we go that's perfect now that might be a little bit too slow or too fast for you and you might want to change that 7 and we could just come in here and delete this and put in a new number but what I'm going to do is instead of setting this to a number we're gonna make a variable so I'm gonna add an event create I'm going to type in variable and we're going to assign a variable so this one right here so I'll drag that in and I'm gonna name this SPD the speed and this is the speed that we're going to go I can't use SP ee d because that is already actually a built-in variable it's a game maker so we can't use that one and now I can assign this to 7 I don't want to take relative I want that to be an absolute variable so now we kind of have a standing for 7 so I can replace 7 and both of these points make sure the minus is still there though and here so that now whenever you want to change that speed variable you only have to change it in this one spot and you should get into the habit of doing things like this because you'll learn very quickly that it saves you time later on when you want to change it because you might be referencing this or variables like this in dozens of events and it can get very cumbersome to have to go back and change it programmers don't like to repeat themselves so if you find yourself repeating a number make it a variable and another handy thing about this is it allows us to change the speed during the game so maybe we can get a powerup that changes our speed all we have to do is change this speed variable because it's no longer set to an absolute number anyway so we can rerun the game just to check that that didn't actually change anything yep and you can see though that if we go outside the bounds of the room but that is still allowed to move and you might want to prevent the bat from doing that so we might want to say if the bat has gone outside the room then don't actually let it move so don't let it perform the spit of card so we're gonna check a condition kind of like our own little event inside this event that's typing if and this is what we want so let's drag this in and what we're going to be doing here is checking if a certain variable and that variable is gonna be X if X is not less than 0 right because that's the very left side so we're gonna say greater than so if X is greater than 0 then we are going to let it move to the left side and to do that we can kind of nest this logic in here so make sure you drag this into here so it's no longer empty so now this is only going to run if this condition is true if it's false it's not going to run let's just test that let's come over to the left side and you can see kind of wax once we get over to here it's gonna prevent us from moving any further but this might not be what you want it's not right at the edge of the room and this is actually because if it's anchor point so remember it's anchored in the center so it's X position right now is at zero so we want to take into account that X offset of its origin so we can literally use a built-in variable called X offset and subtract that from the X so if we rerun the game now and we move over to the left side we can see that it is wrapping it a lot better but it's still not exactly right a little bit of this Friday's actually still over the edge and the reason for this might become obvious if we go through the logic so we have to think about the case where it's right at the edge of the screen why is it still being able to move over one so if the x-value is right at the edge minus the X offset then it is still fulfilling this logic right here which means it's going to be allowed to move over one more time and then the next time it reads it's not going to be able to so what we need to do is account for that edge case so let's subtract one more thing the speed so now we're kind of checking for the spot that we're going to be in so if we rerun that and try and move over now we can see that we're quite snugly at the edge of the screen alright perfect and this is exactly how a lot of game development is going to go you're going to start coding something test it and then realize something's not quite right and then you're going to have to go through the logic of the code find out why that is fix it and then test it again and there might even be another thing you need to fix after that so you always just start off small and get the main thing working and then kind of refine it and add to it as you go so let's come over to the right and we'll also add an if check so we're also checking the X but now we're going to be checking plus the X offset and plus the speed and we are also checking now that we're on the left side so that will be less than and now the room width of the screen is what we want and there is actually a built-in variable cold room width that we can use so we can just type that in there and we need to drag this over to this slot okay give that a test and move to the right and there we go so it's working on the right side as well all right so now that we have the bat moving how we want we can start moving the ball so there are a few things we need to consider about the ball's movement at the very start we want the ball to just kind of sit on the players bat and move with the player and then when we hit a button like space then we want it to fly off in a random direction and from then on we need to set up the balls collisions with the bricks the boundary and the player so that's quite a few things to get done so again we're just going to start small and get the ball moving from where it currently is and just fly off in a random direction so let's come over to the ball and now since the ball is going to be moving in a few different directions we're not going to be using jump to point we'll be using some of the built-in movement variables and functions like speed and the direction so now kind of like how we did with the bricks let's get the ball to pick a direction in its create event so as soon as it gets created and then we'll make it fly off in that direction and it is important at this point to clarify what directions are in game maker it's kind of like the unit circle so zero degrees is going to be pointing to the right in when we go anti-clockwise we're going to be going up in increments of 90 degrees so I want the ball to go up but probably not at the extremes of 0 and 180 so let's say in the direction of 45 90 or 135 and there is an easy action lock that will do this so again let's just type in movement and there is a set Direction random let's try that in and this is going to set the direction to any of these points so let's tick those three but you'll see if you run the game right now the bull isn't going to actually move because all we've actually done is just set the direction it's kind of like if you just turned around but you haven't actually changed your speed so we need to do that as well so that's typing speed and we want to set the movement speed there we go let's drag that in we want to set the direction it's going in and let's just set this to three for now and we'll run that so there we go the bull is flying off in a random direction yours might have gone up left or up right but remember how I said I want the bull to sit on the player at the start before it flies off so we want to actually delay setting these variables until the player hits the spacebar so we can actually do is move all of this so we can highlight both of these and cut them and I want to put them in a different event and that event is going to be a key press this is gonna be when we press the space key and we'll paste it in here all right so now if you run that the ball shouldn't move until we hit space there we go but you'll notice if we press space multiple times it's going to keep running this event and that's because we can just keep pressing this button and it's gonna keep running this logic right here but we only want the players who kick-start the ball once so we need to be tracking something in here to see if we've already done this so we need another variable check but this time we are going to have to set up our own variable so let's come back to the create and again let's type in variable and we're going to assign a variable and I'm gonna call this guard and we'll start off with having this as false so we'll type in false so we haven't gone yet and then in space we're going to check if that variable current is equal to false only then do we want to do this card so make sure you drag these over and then once we've done it for that first time we want to set go to true so we want to assign the variable go to true so now that should only run one time so if we run that again and hit space a few times you can see that it's not letting it do it again but now I want the ball to sit on the players bat until we press that space button so again while go is false I want the ball to move to where the players X is there isn't really an event for this I want it to update basically every frame of the game so we're gonna be using a step event so vinegar step because that is basically game makers equivalent of a frame and this event is continuously run so we can continuously update our position in here so again though we do want to check that go is equal to false and if it is I'm gonna set my ex to the bat but how do I get the bats exposition well what I can do is type in obj bat dot X and using this little dot operator I can access any of the bats variables so now that's gonna set my X to the bats X only when goro is equal to false there so let's run that and have it look so if I move left and right the bull comes with me I can press space and the ball is gonna fly off and there is our next problem so the bowl isn't colliding with the bricks sir syllable we're going to be carting out collisions now so let's go at event and we want a collision with the brick so in the event that this happens what kind of behavior are we expecting we want the ball to kind of bounce off the brick right and ideally there would be a action block for this for bouncing but there isn't one for exactly the behavior that we want however if we open up the documentation for game maker so if we can't to help and open the manual and in here if we just type in bounce then there's actually a function called move bounce all right here and you can see we can use this function to bounce off an instance and although this is for bouncing off all instances within the room if we run this during our collision check it's only going to be bouncing off the brick so we can actually access any of the functions in game maker through a different kind of action block so if I just type in function there is one called function call that we can use to access any of the functions in GML so now if I type in move bounce all and the autocomplete is going to come up for me so just like here but we don't need these brackets we just need the name of the function and here we can pass in an argument so in here you did actually say that we needed to provide it with an argument so either true to enable advance bouncing or not and let's just put true now it does also have an option right here for saving the result of this function in a target just like we had for our random and choose functions so some functions do return a value it's called but some functions just do something and this is one of those cases so this one doesn't actually return anything that we need to say so we can just leave that so this is a really handy action block because although drag-and-drop is really great because it simplifies a lot of GameMaker for you we still can get access to all of the functionality by using this function call alright so if we give that a run then our ball should bounce off the bricks though your so it bounced off we still need to get it to bounce off the bat but we the slightly different behaviors are unlike the break where I wanted to just bounce off in the kind of opposite direction to what it's traveling for the bat I want it to depend on where it hits the bat so if it hits it right at the edge that I want it to bounce off kind of in that direction but if it hits it somewhere in the middle that I want it to bounce kind of straight up so it's gonna depend on where it hits the bat but first thought let's just add that collision event so collision with the bat and now in here we want to change the direction of the bowl so again if I type in direction we're gonna use a different block this time so I'm gonna set point direction because I want the ball to start moving towards a specific point dependent on where the bat is now we're going to take advantage of our sprites origin points so remember how we sent it our origins in the center of the sprites this is going to be really important because now we can draw a line between the bats position and between the balls and then we can just send it flying off in that direction all right so now if we drag in set point direction then this is going to be setting our direction towards whatever point we put here and we don't actually need anything to be relative we are getting the absolute position of the bat in the room not relative to where we are so we're gonna leave these unchecked and just before we want to access the bats X&Y position so we could just type obj bat dot X and obj bat dot y but a word of caution here so a lot of the time with collisions we have to be careful about using this dot accessor because it isn't specific to a unique instance if there are multiple bats in the room then we'd want to only be getting that bad away colliding with and there is a way to be specific instead of putting obj bat we can write other dot X because other is a special keyword that we can use in a collision to reference the other object in the collision so not us but the bat that we have collided with so let's just leave it as this because it is more specific which is always good but actually this isn't quite right because this would be getting the direction to the bat so from the ball to the bat but we actually want it to be whatever this is minus 180 so I'm just gonna quickly after this happens set the direction variable to whatever it currently is plus or minus 180 so if we run that there we go so we're getting the ball bouncing off our bat but you'll see that it's not bouncing off the walls yet so the boundaries of the room sorry let's add one more event instead of a collision this time since there's no objects actually at the boundary of the room what I'm gonna do is use other and then go to intersect boundary so when it hits a boundary and this event is going to run if it hits any of the boundaries but I actually want it to behave differently depending on what boundary it hits so let's just do the left and right boundaries for now so for the left I'm going to reference what's called the bounding box of our object so this is kind of the collision box around our sprite and by default it should just take up the entirety of the sprite and what we can do is check if this collision box of the ball is over the boundary then depending on what side of the box is over the boundary we're going to know what boundary is actually hit so if it hits the left boundary then the left side of its bounding box is going to be less than zero right and it's only going to be the case if it's the left boundary so we can use that to our advantage so we can check if and it's called be box left right here so you can see it coming out if people works left is less than zero then what I'm going to do is get it to reverse its horizontal speed because that's kind of the horizontal component of its space so instead of changing a direction that's another way that we can get it to just flip so if I type in speed again we can set the speed make sure to drag it into that slot and instead of direction I want to set the horizontal speed so I want to set this equal to whatever it currently is but I want to flip it to be a negative if it is positive or positive if it's negative and what I'm going to do is just type negative eight speed because that will get the whatever the horizontal speed is and it'll just flip what it is and we can use this same logic for B box right so I'm just going to copy that and now to check the right side we'll check if B box right is greater than the room width so if we run that it bounces off the right side and let's just check the left there we go so man's is a full F side as well now let's do the top so in the exact same way let's just paste that one more time so now we want if B box top is and now we want less than because the very top of the room is going to be 0 for the Y that's the 0 origin is on the top note down the bottom so we want less than 0 and in that case we want to reverse not the horizontal but the vertical speech so we go the ball should be bouncing all around the room now now for the case where it hits the very bottom of our room that actually means that it has gone past the bat and we want to remove a life but we haven't actually set up the lives yet so this might be a good place to leave it for now and in part two we'll come back to this and set up the lives and the score and finish the rest of our game so I'll see you in the next video
Info
Channel: GameMaker
Views: 55,026
Rating: undefined out of 5
Keywords: YoYo, Games, YoYo Games, GameMaker, Game Maker Studio, GameMaker Studio, game, maker
Id: KdCMftVl1v0
Channel Id: undefined
Length: 43min 30sec (2610 seconds)
Published: Wed Mar 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.