How to Code (almost) Any Feature

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is heavily experimental and I'm mostly talking about game dev but it does apply to pretty much all programming game dev itself was very good for learning programming because of the very tangible results you get from the code you write in this video we'll be trying to teach the process that you have to go through when writing code for yourself more specifically adding certain features and stuff like that rather than just copying other people this is actually very fundamental to coding but I've never really seen it taught anywhere in general this is actually best learned to practice which you'll get by coding obviously however you can only get the experience in that if you know what to be doing I see a lot of people avoiding doing things the way that you learn from and part of the goal of this video is to basically just tell people to stop so the process for programming is just breaking down a feature into smaller logical chunks until you can break it down to the point where it's basically code or basically pseudocode this may sound abstract to some more obvious for others but a lot of people miss this concept a lot of people will try to look up tutorials for pretty much anything they want to implement when that really shouldn't be the case there's a certain category of things that I think you should be learning from tutorials and stuff like that such as the basics of using your library or engine or whatever but once you're putting things together I don't think you should be using tutorials as much maybe if you're stuck but ideally you'd do everything yourself where possible it makes for a better learning experience and helps you do that even more so in the future and similar to that a lot of people seem to think that being good at game development means understanding your engine very well and only how to use all of its functions and everything but that's really not true you can just know the basics and get a pretty long way the most important part is knowing how to put things together you can know all the features of a library or engine without being able to make a entirely on your own it's more about learning that process as mentioned earlier this is best learned through practice so I will provide example so you know what this looks like examples I'll use here will be very simple but the thought process can be built up to make much more complex features I use this process for pretty much everything I make from coming up with at least portions of cloth physics to animating grass that physically interacts with the player and things like infinite world generations stuff like that so let's start simple one question I've seen was how would you add a coin system so that the coin disappears when the player collides with it so there's two parts to this question one is a coin system and two is coins that disappear when you touch with them like I said earlier you really just have to break this down into the logical parts so that you can write the code for it so with coins all you really have are a list of objects that exist at a location generally they don't move around too much they are shown on the screen at that location and in the case of this question when you touch the coin it goes away so this is very simple question there's not too much to breakdown here but when you have a list of something typically you'll use an array or at the list and okay the case of Python to store all of those objects and you can just represent those objects like I said it exists at a location so you can represent that as just an x and a y value and then there's the part I said where you have to render it so all you have to do is draw that coin image at the location of the coin which you can just do by iterating over your array or a list of coins and rendering that coin at the location that that point is at according to the data you have the next part is making it disappear when you touch it this is pretty simple you can do the mathematical part where you can calculate the distance between the player and the coin or some libraries or engines will have futures for collision detection so you just check if the player has collided with the point and then like the question states you want to make it disappear the disappearance is just removing it from the list of coins that you have because if you think about it you're rendering every single one of your coins from that list every frame so if it's not in that list anymore it's effectively gone you could also just add to a variable that's your coin counter if you wanted to do something like that to actually did a video on objects and collisions in PI game both to separate videos so here's another one do you know how to add wall jumps and double jumping this one is really good for breaking down this process so let's start with the wall jumps what is a wall jump well it's kind of in the name you want to make it so that if you're touching the wall you could get an extra jump essentially or you're allowed to jump not necessarily an extra drum so what is jumping event well jumping is the upward velocity that occurs after you press a button typically so say you press up and then you'll jump so what you're looking for in this case is that when the player presses up if they're on the wall this is just for a wall jumping I'm not talking about the rules from jumping from the ground if you're on the wall and you press the up key your velocity will go up now detecting if you're on the wall is another story typically in 2d rectangle based collisions you'll handle the movement on the x and y axis individually so you know what direction you came from the nuchal line I actually have two videos on this concept I recommend the latter but they're my physics video my main series episode number three and I did a more detailed physics video to break down how that works anyway so you can take that value where you're calculating what direction you collided with because you have to know that direction to correct the players position to keep them outside of that object they're colliding with yeah you just take that direction and say if it's on the right or left you're touching the wall so you store that in a variable could just be bullying true or false and when the player presses up you just check that variable to see if they're on a wall and if it's true you allow the velocity to go up double jumping is a bit different double jumping is just exactly what it says though much like while jumping in a sense you get to jump twice so if you want to allow someone to do something twice you just have a counter for how many times they're allowed to jump every time you jump you subtract from that counter and if you want your jumps count to reset say if you touch the ground you set that counter to two once you're on the ground and if your counter is less than or equal to zero when you press it up you don't allow the jump that one can be broken down as just the number of jumps you have and the rules for resetting that count which in most cases is touching the ground touching the ground is a similar to a story to detaching the wall thing that I just went over now here's a bit of a different one this is much more visual someone was just asking me about how I do shockwaves in my games he was referring to this effect that I have in my games where I've got a circle that pulses outward it thins out and disappears this one is pretty simple and concept you've got a circle it starts as kind of a point then it expands that also gets thinner as it expands and once the width of the circles order is 0 or less you just remove it so breaking this down a bit further we need a value that represents the radius of the circle we need a value that represents the width of the circle and obviously the circle exists at a location so we need a value that represents the position of the circle you might also want other values like the color of the circle as well anyways using these values we can just update them every frame to change the status of the circle effect so the width of the circles border will be reduced by certain around every frame and then the radius of the circle will be increased every frame all you have to do is just draw circles at varying order whit's and a die that's pretty much it for the examples hopefully that gives you an idea of how you might break things down logically one step that I can early teach you in this video because it's specific to languages is how to convert the basic logical chunks that make up a feature into the code itself that's something you have to do by learning the language itself and sometimes people will ask me questions like these examples that I brought up in this video and I'll break them down to the point and I didn't in this video some extent and they'll still be confused and at that point if they're confused I would just say that they need to be more familiar with the language they're using or they need to move to simpler problems in general it's just best to start small doing things that don't seem too intimidating they love your ability to follow this process and implement that into code and then eventually you'll be able to implement almost anything you want anyways that's pretty much it for this video if you have any questions you can head over to my discord server I've got a channel dedicated to questions there I'm also working on a dev log series if you're interested in my projects or you can check out my Twitter where I post fairly regular updates on my projects hopefully I'll see you guys in the next video
Info
Channel: DaFluffyPotato
Views: 168,368
Rating: undefined out of 5
Keywords: DaFluffyPotato, brackeys, dani, sebastian lague, coding, codeparade, programming, thinmatrix, next program, code, video games, game development, how to, tutorial, How to Code (almost) Any Feature, learning, randall, Jonas Tyroller, python, code anything
Id: h1o5UzKfZcQ
Channel Id: undefined
Length: 9min 48sec (588 seconds)
Published: Sun May 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.