Construct 3 Tutorial #18 – CASTLE RUN – Collectibles / Collectables – Coins / Gold

alright welcome back in this video we are going to set up some coins as a collectible this will eventually affect the score for the level which will ultimately decide how many crowns you earn which if you saw in the first video I showed you the map how like in a game like a candy crush or puzzle game like that where it has a map and you achieve one two or three stars after completing the level ours are crowns and the coins will affect one of those crowns let's go ahead and jump over to our level 1 layout and come over here to the layers and let's highlight the objects layer and unlock it and then we can double click on our layout and let's insert a sprite and we can insert it wherever we want and we are going to come down here to this animation panel at the bottom right click and choose import frames from files and if we go to our animations folder we will see coins 0 1 2 & 3 so I'm going to select all four of those and open and then it gives us all four of those files in order and I'm gonna right click and delete that first frame because it is empty and I am going to select our animation up here so it'll bring up our animation properties and I'm going to bump the speed up to 8 and make sure that loop is checked and then we can right click on this and select preview and there is our coin and it spins around ok let's make sure that our image point or our origin point is right in the middle and then our polygon I'm gonna make it cover the coin itself on each frame so I'm gonna right click on this on one of these points and say guess polygon shape and then I am just gonna move these around until it covers the amount that I want it to cover certainly doesn't have to be perfect then we'll go to the second frame and this one we can just move these in I think that'll be fine there we go and the next one come in quite a bit something like that and then this one I'm just gonna see if guess polygon shape nope that was a terrible idea I'm gonna undo that and just do it the hard way there we go so each frame is going to have a different collision polygon because the shape and size of it is changing so let's exit out of that and I'm gonna rename this obj underscore coin then I'm gonna grab this and I'm gonna move it into the well I don't have it open so I'm gonna open my sprites and then I'm gonna move it into the objects folder I'm going to move this coin down here and I'm gonna zoom in a little and I'm just going to I'm just gonna place a few in a place let's say one right there and then I'm gonna click or control click and drag out a copy maybe one right there and maybe put like two more over here okay I think that looks good that'll get us started so I'm going to don't click again on the layout and go back to our sprite we're gonna insert another sprite and this time I'm going to come down here right click import frames from strip so I have this strip up here called coin sparkle and that's the one we want to insert and I'm trying to remember how many frames it has I want to say it's 8 maybe or maybe it's 6 I don't know I'm gonna open it and I'm gonna leave it at 6 because I think it might be 6 so the horizontal cells are 6 cells across so it's going to chop that strip up into 6 even pieces and the vertical cells is 1 so it's not gonna chop it vertically and I'm going to import that I was right I have 6 frames so 6 is the magic number okay our polygon box does not matter let's set our image point to right in the middle if it isn't already and we can zoom in here if we click on our animation up here we get our properties I'm gonna make this one a little bit faster let's say 12 and then we can preview what that looks like and there you go and I'll play it again and it's just a little sparkle that I made for when you collect the coin kind of like you would see in a Mario Brothers game okay let's exit out of that and I'm going to rename this coin sparkle and I am going to click on it in the layout and just delete it let's go ahead and head on over to the objects of inch sheet and I'm going to right click add a new group I'm gonna call this one coins coins there we go and I'm gonna add an event to coins I'm going to grab our player sprite let's type in overlapping another object and that object is going to be the coin there we go and when that happens we are going to spawn another object to the coin so let's go find our coin which is going to be in our objects folder I'm gonna pick the coin and I'm gonna type in spawn another object and we're going to pick our coin Sparkle and the layer is going to be the objects layer and the image point is going to be 0 and I'll show you why in our objects folder our coin has an origin point and the number is 0 and it's right in the middle so this is going to spawn this object at that image point all right next thing we want to do is get rid of the coin so let's add an action let's go back to our coin and we can type in destroy I'm gonna play this and when we collide we sparkle and I don't know if you can see this or not but there's little yellow dots right there and that's because it created the object and it played through the animation but the object is still there because we didn't tell it to go anywhere so we could add a weight action and just wait a small amount of time and then destroy it then you have to kind of timeout how long the sparkle lasts and if the device that's being played on is moving at a different frame rate it could kind of mess all that up so instead of using that method I'm going to wait until the animation is done so we're going to add a separate event to the coins group and I'm going to pick the coin sparkle object and down here in our animations area I'm going to pick unfinished so triggered when an animation has finished pick next and that animation is going to be it was animation 1 I'm going to go rename that so let's go into our Queen sparkle and let's rename this just I don't know coin sparkle all right so now I can go back in here and change this animation one two coin Sparkle there it is and that has to be in quotation marks all right so when that is finished we can go grab our coin Sparkle and type in destroy let's play that when we collect it and it's nowhere to be seen and I think that's a pretty neat little sparkle effect let's go over here to our global variables tab and I am going to create a new global variable and that is going to be called coins collected and this is going to keep track of how many coins we have collected in a level back on our objects once we have overlap the coin we've destroyed it and played the sparkle effect I am going to go to system type in add and we're going to choose add two we want to add two coins collected and we want to add one so we can hit done all right now let's head on over to our level 1 layout and we are going to create something some text to show us how many coins we have created so listen actually let's highlight our HUD I'm gonna lock the objects and unlock the HUD so now we're on the HUD layer I'm going to double click and add a text object and I'm just gonna place this up here in the corner and I'll zoom in a little and I'm gonna change the size of this because I want it to be a specific size to match a frame that we're gonna put around it let a little later on so 128 by 30 I think will do and then let's scroll down and let's change the text to coins all caps : and then for the thought I'm going to choose console us I think that's maybe how you pronounce that we'll go with it and then let's tick bold and change the size to 16 and down here the horizontal alignment I'm gonna leave it left vertical alignment I want right in the center and then the origin is going to be the left so that's gonna put the origin you see this little dot right here it's at the left middle so that's where we want the origin and that's going to be pretty important later on I'm going to with this selected highlighted I'm gonna rename it txt underscore hood coins let's change the color to white so we can see it on our screen and I'm gonna go into our main event sheet and I'm gonna right click add a new group I'm gonna call this coin count add an event say system every tick so every tick I want to set our text to how many coins we have collected so let's add an action I'm gonna pick the text HUD coins object and I'm gonna type in set text in our text what we want the text to say is going to be in the quotation marks and I want it to be in all caps coins semicolon space and then the end quotation mark and after that I'm going to type in an ampersand and then the variable that is keeping track of how many coins we've collected which is called coins collected and one more thing I want to set up in our initialize main I want to go ahead and this to zero at the very beginning of the level so every time we start a new level or replay a layer we want to reset that back to zero so I'm add an action go to system and set value of coins collected to zero back on our level one as I have explained before we have this dotted line here this shows us the size of our viewport and because our HUD layer has 0% parallax and a 0% scale rate anything that I put in this dotted line area is going to stay on screen in that area so I'm just going to put this up at the top this is about where we're going to have it someone there the general area will change all that later and I'm going to preview the level so when we start out it sets it at zero and then we collect one two three four and then if we die we restart the layer and we're back at zero and we can count the coins again all right the last thing I want to do in this video is go ahead and set up the coins for the entire level so I'm going to keep those four there and if you want to place your own coins in your own level especially if you have a different design you know feel free to do so but if you are following along with me I will show you where I am putting all these coins so you can get them in the same area there is strategy to my coin placement and that is as I was talking in a previous video about teaching the player how to play the game without giving them instruction so this first level here this first ledge that we start out on there's no traps there's no spikes all we have is a barrel at the end that we have to figure out oh we got to jump up here to have enough distance to jump to the next ledge but we can kind of break up this boringness with oh here's some coins to collect and I put these two down low because you don't have to do anything you can just run in collect your first two coins the second two coins you're actually gonna have to figure out the timing of the jump because you could jump too soon and only get one or jump too late and only get the other one or miss them entirely so there is a little bit of strategy but it's it's an easy strategy so we're slowly teaching our players our audience how to play the game so I'm gonna give them actually I'm gonna lock the HUD pick objects layer unlock it and then I'm gonna give them another freebie so I'm gonna just keep ctrl click and copying out these coins alright my next one I'm going to put right after the spike actually I'm going to click on the layer and I'm going to go to my grid size and change it back to sixteen by sixteen sixteen sixteen by sixteen that way I can move it in like that so here the strategy is typically your instinct is you're going to try to avoid this spike obstacle so you're probably going to start jumping right about here and if you do you're going to clear the spikes but you're also going to clear the coin so a an experienced player of this game is going to know that you got a jump before but not too soon because you don't want to clip yourself on the spikes so you jump a little bit before and land on the coin as you keep going and I'm gonna kind of do the same thing here maybe right about there so the idea here maybe one over there we go so the idea here is if you jump too soon well you could land on the spikes or hit the spikes but if you jump too soon you could get the coin but you might hit this the side of this spring which will send you back in the other direction now you can avoid all this stuff again but that adds time you can't control your character other than the jump and that'll make it longer for you to get through the level which is going to end up being one of our bonus points I'm just trying to explain the method behind my madness of where I'm placing these coins I'm not really placing them wherever I have a strategy behind it I'm gonna copy and bring one over here this one can get kind of tricky because if you're coming this way because you don't want to jump up here but if you come this way you see that coin if your instinct is to jump up and get it by the time you land you're gonna hit that spike but if you have patience you wait you pass under it you jump over the spike parkour off the wall come back and then jump again you can get that coin and then make this jump as well so like I was saying before we're kind of training our player on how to play our game and you can implement these things on your design if your design is different than mine you can still implement the idea of getting players to make different decisions so I'm gonna put one over here ideally you wouldn't need to come over here but if you do by accident you get rewarded with a coin and then I'm going to put one right about in and up so what happens here is we jump up here and we hit this wall to turn around this is a pretty big gap to jump over instinct would be to start jumping right about here to make sure that you get the gap but you can actually jump a little bit before it just enough to collect that coin and still land on this edge it takes a little bit of precision but it's definitely possible now the idea I'm gonna draw drag out another copy the idea of the level design from my perspective is when we set up the goals for the coins I'm not going to make it to where you have to get all the coins on the level two reach the goal you'll just have to get a certain amount and not all of them are going to be available if you are trying to get through the level as quickly as you can because there's going to be a bonus for your speed so in this instance there's no way to get this coin on your first way through you have to jump up on this barrel drop down and by the time you drop you're gonna be past the coin and you would have to hit this the side of the spring to turn around go back collect the coin and then you'd hit that wall turn around and then go back to the spring this isn't necessary this is gonna be one that coins it you're not going to be required to get to achieve the bonus but it is there and if you're doing good on time this is a pretty short space so this might be one you go back for just to make sure you get it if you've missed one of the other easier coins in the beginning of the level drag out another copy and zoom in here I'm gonna put this one right like that now this looks like a gimme right here but it's really not because in my play testing of this design there are often times of where ever you time your jump in this area there is a possibility of hitting the wall bouncing off the spring and sliding up through this gap right here and you never get that coin and if you continue going you know you're gonna bounce off this wall and then you're gonna jump to get to this level because then you're not going to be able to get that coin so if you pass that coin you won't get it unless you fall back down and if you fall back down you got to go back all through this again so like I said there is strategy to all the coin placement drag another copy to write about I think maybe maybe right there okay now this one this one's a gimme cuz you're gonna jump up here and fall down here you're gonna hit this spring and it's going to bounce you this other direction you're gonna lay in right on it you're gonna get that coin every time but then you're gonna have to jump over this ledge immediately that's where this coin comes into place I'm gonna put him right on the edge and actually right at the the halfway point of the coin so what this does you're gonna jump and you're gonna clear that coin every single time because there's just not enough room to jump quick enough to time it out to where you get that coin so you're going to clear that coin you know walk all the way to this end you're gonna hit this turn around if you have patience and precision you can wait to the last second collect that coin then jump that's going to put you on this edge of this ledge and you're gonna have to immediately jump again and make it over the spike now if you get that done there's two things that can happen one if you don't time it outright you could jump too soon and you could clear the spike but you could fall down here and once you're down here you can't get back up but you do get the end goal so I'm going to reward the player for jumping correctly and timing it correctly so I'm gonna drag out a coin to right about there at the the very end actually I'm going to move him up one and that I'm going to copy two more times so again there's a little bit of strategy here when you clear this you get three coins right well maybe because this spike is an active trap because we have our death collision here and in fact I'm going to unlock collisions and I'm gonna turn off snapping for just a second and I'm going to put that in just a hair to make sure that we're hitting that wall before we hit that unless we clear the wall which is possible so I'm gonna reset the snapping and lock my collision go back to my objects so what happens here is once you clear the spike and you're here your instinct again you've been playing games for video games forever your instinct is going to be to jump and collect all these coins on your way down but if you do that you're gonna clear that wall and you're gonna hit the spike you're gonna die and what happens when you die in this game you start back at the very beginning there are no checkpoints so strategy is key and experience is worth a lot when you play a game like this so the way that you would do this correctly is once you clear that spike you land here you wait till you get to the wall and then you jump and by about the middle of your jump you hit this wall which will send you in the other direction you collect all three coins and then you just fall down here and then I'm going to do one more little strategy here so the way that I have the amount of coins to achieve the goal set up is whenever you get down here you will have the opportunity to just glance up at the top of the screen and see how many coins you've collected and where your time is if you are within the time goal you have plenty of time left then you can go and collect one more coin especially if you need that coin to reach the coin goal and in many cases you're going to be right at the coin goal if you went through this fast enough to try to beat the time as well so you could jump into it and in the level right then and there or you could wait I mean we're talking about maybe one second extra and sometimes one second extra can be the difference but you would just keep rolling until you got the coin then you would jump up and hit that on your way back so that is the strategy I wanted to use a little level design game design and actually I want to break this up too so I'm going to drag down a copy and I think I'm going to put it maybe something like that and something like that so again strategy patience and experience of playing these levels is going to pay off okay I know that was a lot of explanation but I wanted to be able to offer ideas on game design not just programming and using behaviors and doing artwork there's a strategy when you keep the player or your target audience in mind with that said we are done with the coins and I'm going to end that here in the next video we are going to add to our HUD we've done the coins and the next one we're going to do the timer and we're going to set up all the logic for that so I will see you in the next video and don't forget to save [Applause]

Leave a Reply

Your email address will not be published. Required fields are marked *