Transcript for:
Game Development Lecture Notes 🕹️

hi everybody here's Christian and this is because it here I'm still I'm still sorry about this keyboard that's why it's very late but it's still so great sometimes you know to motivate you to do the things that she's supposed to do you do kind of like treat yourself a little bit you know and this is definitely a huge treat so today we're gonna have another treat as well because today I will actually do so we're gonna actually redo some of them I'm fixing some things here so we are going to finish up maybe the power ups so later on we're gonna move on to the juicy stuff so last time around we made the multiple happen but now we have to get real about about how multi-ball interacts with the other power-ups and I've been doing some soul-searching and I initially I thought maybe you know when you pick up another powerup like all the power-ups would cancel each other so there would be no crossover between the power-ups so if you pick up a powerup you cancel the previous one automatically which for example makes sense because there are some power-ups that we have that cannot be at the same time like we have a wide pedal in a narrow pedal and they kind of like cancel each other but now I am no longer sure about that especially with multi-ball it's kind of weird to cancel a multi-ball because you already already have the boss on the screen so if cancel multi-ball you would have to make the balls disappear and then it's kind of like the question arises which ball will disappear you would have maybe it would be possible it's not impossible right but it's just not like perfect it's not like there is no natural solution to this there is no no intuitive solution to this and also I think where big draw of what the multi ball is about I think it's like the mayhem it creates like there's suddenly all those balls on-screen all those things happening there's there's something to be said that even though some of the combinations of the power-ups could be like stating and very broken like especially the mega ball and a multi ball like the ball that goes through the bricks and also multiple balls at the same time that seems broken but also nearly and it's it's fun there's no way around this something's broken things are fun there's a only way to go even further tangent like something if you think about something like RPGs where usually when I ask my students like what's our RPG about and they say like oh it's about you know being a character and developing a character and stuff like that and then playing a character but it's not like it's RPGs about player systematically breaking the game if you think about it because you you know you upgrade to character until the game becomes pointless until you can wipe out all the enemies and for example the best RPGs stuff like Final Fantasy 7 I'll do the ones that give it like this completed system that allows you to actually create those crazy combos that make you like an unbeatable badass and that's not really like character that you're not really playing a character you're just breaking the game in a very elaborate way so this that's kind of like a very complicated nation where I think the power-ups should actually stack I have a I am I mean we need to do some thinking though so if they are going to stack we have to some of the power-ups have timers so I have to keep track of which power-ups actually have timers so slow down has a timer life does not have a timer also I want to keep track of which exclude each other because some of the the power-ups will cancel each other but we're gonna see a real quick that there is not too many so catch sticky is a bit of a tricky one this is the one that we're going to deal to today because the way it works but multi-ball is kind of weird right because you have multiple balls and one will hit the pedal and that will be stuck to the pedal and so what happens if in the next one hits a pail that also we're gonna be stucked in which then the question is like what happens when you launch the pair the balls and what if you if there you have already balls stick to the paddle but there is still another flying around and then maybe you pick up another sticky and then second the second ball also sticks to the paddle we don't you don't wanna have situation where both balls are stick to the paddle I think I think that's something that we should avoid so the catch and sticky is not something it has no timer I think we have to it should not be shot and should not have a timer I think it should be like something like okay the next ball gets gets caught so I'm gonna check this if this has no timer but also no multi multiple no more to put stickies that's very important so that's kind of like restriction we have to program in expand has timer it works for only a limited amount of time but also cancels reduce and equally reduce is the same thing it has a timer reduce also also has a timer and it cancels it cancels expand I think I misspelled canceled I'm sorry I'm sorry don't be afraid don't don't don't judge me please okay so and multiple also has timer very important a mega bonus timer multiple has no timer my the idea being that if you can keep all those balls on the screen go ahead man like it's it's kind of like a very powerful power so no restrictions we have to also watch out what happens when you are actually your balls actually stuck to the pedal and then you pick up multi ball what happens then what's the best solution well I guess then you will launch the multi ball you will launch the stock release again there is just no way we're talking about balls there's really no way this won't there's there's a there's no way it won't be can't be misunderstood as something dirty so please please keep things civil in the comment section guys we are really talking about what breakout here cool so I'm going to keep this around as a reminder of what what things were on a program right good so let me start out let me start out with the sticky part because that's kind of like something that we had all this time oh yeah by the way I wrote something another some some other two things I don't know if we have time for all of these today but so I was thinking about maybe reducing an amount of balls that that your when you pick up the multi ball may be reversing your move reducing the amount of ball that your ball splits in two from three into just two that opens another can of worms but we're gonna get to that in a second and then yeah if there's already multi balls on the screen and then you pick another multi ball I want to split a random multi ball in to enter into pieces okay so with a sticky again with a sticky I always want to have just one ball stick to a pedal its it will just create a huge huge huge pain if there's multiple ones so I so this sticky true this sticky true is I think very important because it kind of like makes sure that we know that the pedal is sticky right but also I think if if there's multiple balls on the screen and one ball can be stuck to the pad I think now we have to differentiate between the pad being sticky and so a ball can stick to it and also tracking which ball is actually stuck to the pedal that's there's a different way of thinking about this that we have to keep track of and I think the way we do this is by adding and now this is the you know this is the the payoff to the fact that our balls are now objects we can now add properties to those balls and so I want to do this and when we create a new ball I'm gonna add a new property to our boss and that one is stuck so new balls are automatically not stuck stock equals false and if I copy a ball I will obviously copy the stock ability but I don't think that it will actually happen okay so far so good let me get some spaces in here to make this a little bit readable I don't know why why I decided to make things so so crammed in here cool and so let me go to the update function because this is where now the things change update ball see for the way we candle this right now there was the Stucky a sticky variable and if that was true the ball was stuck to them to the pad but now there's there can be we have to check which ball is actually stuck to the pad so instead of just checking for sticky you can only see this actually pretty pretty natural where we gonna go if my ball dot stuck then I will draw this ball on on the pad there is one more problem here there is the position of the stuck ball is stored in sticky X but I don't think this is will be a problem right now right so if my ball stuck equals zero by the way because this is a false or true variable U I could have just wrote as something like this just a reminder but you can also if whenever something is just true and false you can just plug it directly into an X statement so if my ball is stuck then the position is gonna be the position of the X plus like X okay and then my ball pad Y okay yeah that's good that's good hmm so now I need to just make sure that when the ball hits the pad and it's sticky then I want it to actually stick to the bow to the to the pad where is this whereas this mr. Potter ball hit pad there we go cash powerup yes so if power up equals three so the way we did this is there is so far we Kiwi we had these power-ups that we're tracking and if the current power up its on is three then we then we we would catch the ball but now I think we're gonna do it differently where we're gonna check if the pedal is sticky if sticky and my ball so forth or so forth then and then if I do this sticky then the pad is no longer sticky actually equals false and then the sticky is gonna be set and then my ball because you know now we declare that actually the pad is no long sticky is just a ball of stock so my ball stuck equals true there's one one problem still of course and that is there's multiple problems still but that's that's something and we should maybe create a function that makes sure that if there is as already a ball somehow stuck to the to the pad maybe we did some mistakes maybe you know pick it up too sticky twice or something just make making sure that release the keys released at balls I'm gonna call it really stuck it's basic like a small function I'm going to create that just makes sure that if there's any balls currently stuck to the pedal it will get released at this point like there is a new new ball that's coming in that's about to get stuck to the pad and if there's really a second ball early on a pad that gets released so the new one gets stuck instead again I know not sure if this will situation will happen or just making sure that there is never situation where if two two balls stuck to the pad and so I will write this real quick it's gonna be very short function I'm gonna put it underneath all of this oops let's really get sauter way function really stuck and so let me let me real quick steal some some code from from update game where we iterate through all of the balls here big ball loop I will just iterate yeah okay so I will actually go forward through entire loop I don't know the B is a good idea yeah it's probably good idea and then so how do we do this how do we actually have a good on on on a game Franchot we actually released about the ball if power up equals 4 then nevermind um there we go sticky there you go a sticky then ball the x equals 1 yeah there we go there it goes if well x equals mid oh well oh we still have ball X going on in here that's weird that shouldn't be happening right I understand so let me see update ball how do we did oh yeah okay so we're actually changing the position of the ball so that should be no problem because what we can do now is yeah we have to rewrite this we have this this is this is but this is bad this is a bad situation what's something we can do right now is so yeah so we're gonna check if this ball is stuck first that's that's a very important if ball square brackets the I which is let's go with I with index so if ball i dot stuck then and then this is where we are releasing it right so ball we're gonna do it in the long way dot x equals and this bam easy-peasy for Bridget right yeah we're making sure it's gets released somehow somewhere and then it's no longer stuck I like this so iterating through all the balls seeing if any of them are stuck to the pedal if they are stuck to pedal we are setting there we are making sure that they're still on the screen and then we're just releasing them that's interesting okay so something I can actually do now is I can actually reuse this function when we are actually releasing the balls because we notice that this is awesome a really old code that still used the ball underscore X C or C well underscore X so there we go so something we can do here now is sticky was actually an back as well so something you can do is now is just say like we never just repress the button we release the balls and that's that's that's gonna be actually it and we don't need this this stuff anymore that's that's one that makes our entire code a lots more simpler we I don't actually care if they if the updates with the upgrade was actually with the power up was actually picked up we just we just do it the only situation is that we have to deal with this this so if there's if the sticky is on then we have to actually change the yeah we're changing the X and y direction and that's actually I just realized something it's we're actually breaking as well I think the the angle stuff it actually doesn't really interact with really well with our angle stuff so haha good thing I checked ok so how are we going to do this there ideas here does that when you press left you also change the direction which the ball will that is currently stuck to the pedal will fly how are we going to do this I mean I mean we just gonna it's a bit silly because we have all this code in here and we kind of have to copy this code now and put it on in there that's good let's okay let's just copy this one and just put it in more one more time in here instead of really stuck it is gonna be we're gonna call it point stuff point stuck and then mm-hmm sign so the ideas there is a ball stuck to the pedal and we just want to make it when you press left go should go left and you've press right it should go right that's kind of like this fun mechanic that we had there where balls that you start stuck to the pad you can kind of target where they should be supposed to go and the sign we're talking about the sign because the x-direction either goes negative then and this when it goes negative it goes in this direction for me from your perspective and then if responsibles goes in this direction and so negative is left and positive right so we want to be able to go through all of the other ball array and see if there are some balls stuck to the to the pedal and if they are we're gonna go we're gonna set the sign of the Y x2 to this so so this is the part where we have to think about this so if there's already negative we yeah so what way means do we have an absolute have to Google is it a little bit so um I'm getting a lot of information here let me look this up real quick so Piko Piko 8u absolute function do we have absolute IBS there we go yes we have a BS so the ABS function the ABS function returns a number and removes the sign it's always positive so we have we have like minus 300 it returns 300 if you have 300 it returns also 300 so it kind of strips often if there's an - there and it strips it off which is very useful because when a strip off the sign and we're going to substitute it whatever sign we already had we are actually given by the by the function so ABS stripping it and then multiplying it by sine so this way this function will actually take whatever whichever Direction is follows this ball was flying and puts different bone in this place at different sign instance will just get I still can't can pick up my mind whether to ethical spaces to make it a little bit more readable or to remove the spaces so it's actually the entire line is visible on the screen okay so look so point stuck this is actually a lot more complicated I thought I think we're gonna have to split it into two episodes after all um okay so it's a sticky here but are we actually gonna not gonna do this we're gonna just go inside point stuck minus one and if there's any balls point an edit to dip into the paddle they are gonna get pointed in different directions and same thing with this guy here but this time we're gonna go positive see because again because we have like this parameter this argument called sign and we just multiplied the absolute value of the X Direction with the sign argument so you know if we do this like this we've if you send minus 1 to the point stack function it will go right no left sorry and if you put like a positive number like a 1 here then it will go right good let me see if this works wait a minute yeah there's one more thing we have to do we have to do so when we restart when you serve the ball that ball that gets served that needs to be stuck and sticky has to be turned off so there we go serve ball and then I'm gonna go ball one top stock equals true and then it's not gonna be sticky like so save run there is a problem so okay there's some somewhere we're talking about my ball dot stuck and it says it's yet it was it was here yes of course yes yes yes yes yes see this part is my ball equals Paul VI this one we have to put it in here now now it works okay so see I already see that the behavior is the same so that's good okay with the way we draw the ball is still Oh interesting Oh gets it back the realized good so some behaviors are bad that mean that some some things still don't quite work never mind let's let's fix those first let's let's fix how we draw things um drug in there we go if sticky then we're gonna draw a line that's not what you want to do we want to do this now at per ball on a pair ball basis so we're gonna go to where we're gonna go now to where we draw the balls where do we draw up into balls there we go and here we're drawing the balls and then we're gonna add this function here to our ball drawing think and here we're gonna ask if the ball is stuck to the paddle if ball I God talk then and then we're gonna draw the line and that's good and of course not the first ball but the eyeball eyeball this is the best it's a very long line I hate long lines but we are you gonna keep edits replacing all the ones with eyes and here okay so this is soft but there's another problem here that problem is that somehow sticky got set and we didn't want to sticky to get set so I want to actually look for all the instances of sticky in our program how does it work certs ctrl F first one is saved and we're gonna search for sticky I'm gonna make sure that we don't have any situation where we accidentally set sticky to true okay ctrl G to get the next one okay G haha see already finding something when the game starts we're gonna assist we are setting sticky to true let's not do this continue where is this another sticky equals true when the next level is true well again let's not do this actually when a game starts let's set sticky to false so we initiate sticky and in some way sticky is false and then when the next level also happens we also reset sticky to false alike because if if the pad was sticky we no longer wanted to be sticky okay okay it's still sticky dough so it seemed sticky mm-hm okay this is good here sticky false your sticky false heuristic X that's okay okay that's good okay I'm not sure why did we get the balls stuck to the the only way I would this is really okay let's debug this so first okay so this pace normally now I'm going to pick up something and now we're getting those balls stick to the pedal okay so the new balls when you copy the balls they are not being copied correctly ah there we go yeah there was a mistake here and if you notice this while I was typing this and you did do it well so we put the angle into the into the stuck and that's how we got weird results so let's run this [Music] we're getting okay but we that's an issue that's that we got to deal with one at one point oh I want to actually finish the level to see if they have the new level begins if we if it gets good stick behavior let me finish the level oh yeah okay nevermind that works good okay so we already really far into this let me let me think about so what we need we need when you pick up no multi-ball I actually want to wear this the sticky powerup I actually want to now have the sticky the sticky pad so we have to change the way the pills work now at least for a sticky powerup get there we go so this is the catch or sticky one so this time around I will not have a timer and I will not no longer have to power up so what we instead gonna do is to be gonna go just sticky equals so now ya know multiple stickies is the problem here so if there is already a sticky ball we're not gonna get a second sticky ball so what we actually have to do here is we're gonna have to see if there's any sticky balls we could also release all the balls and then see say like okay and now we're gonna get a second sticky but I think it's fair it seemed kind of erratic I think I think it's better if we just there we go if we just check if there are stuck balls and then I'm gonna create has talked equal spots and then there's a new variable that where we that will remember if there is any stuck balls we assume that there's no stack bolts but be not sure if we're gonna find a stack ball we're gonna have to say okay head stock equals true and then at the end of this for next loop you're gonna send say if has stuck equals false then stick equals true basically if we haven't found any sticky balls we're gonna set the pedal to sticky - to wait for the next for the next for the next ball to hit the pad there is one more thing though will multiple stickies okay so that's good so there's one more thing I want to do when we pick up the multi ball I want to release the sticky balls so multiple so in just in case so we don't don't be on copy a ball that is already stuck to the pedal so these sticky stuck I think release there is a power up in the power of timer I will remove both of them because multiple no longer has a timer okay so what I want to do is by test in order to test this I will actually make sure that when we spawn the pills we are just spawning two types of pills like this right no like this yeah and then actually let me let me undo this real quick and let me let me comment this out um so what I want to do now is yeah like this so this should give us a number between 1 0 and 1 and then if T equals 0 this is this is just temporary code I just want to have a situation where only we only get stickies and multi balls else so we're gonna basic flip a coin and then if it's head we're gonna we're gonna set it to multi ball and if its tail's we're gonna set it to sticky which one is sticky I think it's 1 2 3 no 0 1 2 [Laughter] [Music] [Music] okay so we have no yeah it works it basically works because I picked up a multi ball and release the sticky immediately right this is getting very long episode I'm actually reconsidering this maybe what we're gonna do is we're not gonna actually release all of the stickies but we just gotta release the sticky if it's the sticky there's a ball that is stuck to the pedal that is actually being being copied but that's something every think we're gonna do it in the next episode because this is getting very long it has been a bit of a kind of like confusing episode perhaps because we've been like going through a code and we're writing stuff and fixing like old things but I think we're almost fixed a sticky so I want to actually put the the texts that we had here I'm gonna put it in here oops yeah that's why not why not so what I want to do is slow down timer this is fine catchin sticky that's also working already mmm this is this is these two things this will have to deal with and then unsticky copied porn and stuck or release like this slow down timer that's good we already did this expand we're gonna have to do the expand reduce just doing like a to-do list I'm gonna break three do each on one of the individual power-ups so will they interact with each other correctly Mega Ball has a timer and multiple already behaves correctly easy-peasy febri okay so these are the things somehow we are working on ourselves backwards and this song you get where you feel like you want to add more more up like you want to just fix stuff per story there and you're actually getting like getting further away from the from the goal but in fact what happens is you've thought you were a pretty closer to go but actually we're very far far away and you actually realize how far you were really right from the goal so we just realize that these are the image or steps we have to go through in order to get those those upgrades done in order to implement all the things that we set out to do but that's something we do and Excel this was very long sorry about that guys it's your next turn around