
Or in other words whatever is in those brackets.Īnd after that it runs the next statementĪnd after the second statement it ask the previous question again. Then after that it asks a question, and if the question is a true statement 0 is in fact less than 10 So starting out it will run the first statement, making i equal to 0. If you don’t know what that is let me explain, To do this I’m going to use for statements. Now that we have limits we need to have the player move with his speed. This make it so the player can never fall faster that his limit.Īnd again the same for the other direction. This says if our horizontal speed is greater than it's limit, it then become equal to it. To prevent him from gaining too much speed and breaking the game. The first thing we will do is create the speed limits the player can act in.
#SONIC EXE 2 OF PART 1 CODE#
The reason I’m using a script and not adding this directly into the step event is so I can quickly reuse this for other object, and to keep the code neatly isolated from the rest of the player’s scripts.

This script will handle all the physics or in other words how the player interacts with the solid objects around them. Now we will go scripts and create one called This will tell us if sonic in on the ground or in the air.Īfter this our Create Event should look like this. This is how fast sonic will fall while in the air.Īnd last we will create another variable and call it ground. Now we will make another variable called grv or gravity This is how much speed sonic will loss when not in motion. Now we will make another variable called FRC for friction. Now sonic games are momentum based platformers, so sonic will slowly gain and loss speed.įor this we need to make two more variables. They are going to represent our horizontal and vertical speed limits. They are going to represent our horizontal speed and vertical speed. In this we will be making some variables that we will be using a lot. this is how you code in studio 1.x and below.) Now with that all done, lets head to our player object and start coding!įirst add a create event (if you are using studio 1.x or below to will want to also go to the control tab and add a execute code action. Now lets give obj_player our player sprite, and obj_block our grey block sprite. This is our first child for our collision master. This will be our player object, the one which the player controls. Now we will be creating two more objects, This is our base collision object, one that sonic (or whoever your main character is!) In this group create a object which we will call obj_wall This group will hold the parent objects for any collision type we make.


Now we are going to want to go down to our objects and create a group by right clicking on the folder. The grey blocks not to important, just make it square and origin in the top left. Make the blue ball 32x32 pixels and center its origin point. Nothing to crazy just a grey block to stand in for collision and a blue ball for sonic. Starting out we are going to want to make two sprites for testing purposes. If your using Game maker Studio 2 you want to create a GML project. So for this tutorial we will be building the bare bones foundation that every tutorial after will be Now With all that being said, Let’s us Begin!
