![]() The only one you really need to be concerned with at the moment, other than gSpeed, is onGround. You may have noticed that gSpeed has already been defined for you, along with a couple of other variables that are important to collision. Open the create event in the oPlayer object and add the following line to the end of your //movement section. all have a huge impact on how your jump feels. Gravity, air control, jump power, variable jump height, hang time, coyote time, etc. There are a lot of moving parts to having a good jump. Jumping is something that a lot of games have, and surprisingly, a lot of games get wrong. For now, just enjoy the collision goodness as-is and we’ll come back to it later. The details of how this code works easily deserve an entire blog entry of their own, so I won’t be explaining the ins and outs here. ![]() Now when you run and then crouch, you will slide!īefore we get into jumping, let me just preface by saying this version of the project contains some collision code. Open that up and change the xSpeed = 0 line to this. Just for fun, let’s make a change to the crouch_state script. (If either coordinate is less than or greater than the size of the room plus the width of the sprite, move_wrap relocates the object to the opposite side of the screen.) This function checks your object’s x and y coordinates, adjusting them as appropriate to ensure your character doesn’t actually leave the screen. If you are wondering about the move_wrap line, that is just there to keep our character on the screen if you run him off. Generally I try to keep my dSpeed higher than the aSpeed. Go ahead and fiddle with the aSpeed and dSpeed values until you get something that feels good to you. When you stop pushing left or right, your xSpeed will approach 0 by your dSpeed. When pushing left or right, your xSpeed will approach your mSpeed by aSpeed. Now your character should have some acceleration and deceleration. XSpeed = approach(xSpeed,-mSpeed,aSpeed) Open the normal_state script and make the following changes to your movement code. Now, let's put these to use! We are going to use our old pal approach to make the movement nice and smooth. The first variable, aSpeed will be our acceleration value, dSpeed will be our deceleration, and mSpeed will be our maximum speed. Under the //movement comment go ahead and add the following variables. Let's start by adding a couple of variables to your oPlayer object’s create event. This can give your characters a real sense of weight, and make them feel much more grounded in reality. One of the easiest things you can do is add acceleration and deceleration to your character's movement. That said, these concepts can be applied to almost any game to a varying degree. This is by far the most subjective part of game development, and it depends heavily on the kind of game you want to make. This will help you squeeze some more life and feeling out of your games, and improve the quality of your games overall. In this GameMaker basics post, we are going to talk about adding some juice to your character movements and animations. Also, you will want to download this project file, which contains some collision code not included in this blog. This entry relies heavily on the previous blog entry! If you have not been following along, I recommend checking out the previous two blog entries on drawing sprites and setting up a state machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |