Make a plateformer game with Game Maker or Game Maker Studio.
In the part 1 there where some other problems :-While the player is falling and the jump button is not pressed the player stay standing or when the player move right or left the player run while he is falling.
So to fix these problems we will start first by making two new sprite :
-sprPlayerFalling.
-sprPlayerJumpMove.
Then we have to add a new variable to indicate if the player is falling or not :
Create event:
falling = false;
Step event :
And then we will go to step mode and change somthing :
We have already this code :
if place_free(x,y+1){
gravity = 0.5;
}else{
gravity = 0;
}
we will add some codes:
if place_free(x,y+1){
gravity = 0.5;
falling = true;
}else{
gravity = 0;
falling = false;
}
The variable falling will return true if player is falling and false if it is not.
Then add this code in step event :
if falling && !keyboard_check(vk_up){
sprite_index = sprPlayerFalling;
}
This code will check if the player is falling (falling = true) and the up key is not pressed then the sprite of the player will change to the falling sprite.
If you test the game now there should be a collision bug when the player jump and when he touch the ground when he try to move the sprite change to the falling sprite and not the running one.
You have to change the player's mask, there are too many way you can make a rectangle and assign it or assign the Idle sprite so that the whole object will have the same collision shap :
Here i have choose the Idle Player sprite.
Now the bug is fixed, let's continue.
We have now to set the sprite of the player moving when it is falling, we have to go to the step event:
At this part of the code that we have just to write :
if falling && !keyboard_check(vk_up){
sprite_index = sprPlayerFalling;
}
We have to add some instructions :
if falling && !keyboard_check(vk_up){
if (keyboard_check(vk_right)) or (keyboard_check(vk_left)){
sprite_index = sprPlayerJumpMove;
}else{
sprite_index = sprPlayerFalling;
}
}
This will check if the right or the left while falling if true the sprite will be the sprPlayerJumpMove if not the sprite will be sprPlayerFalling.
Congratulation, you have made a complete platformer game with GameMaker you can check other tutorials for making ennemies or other.
In the part 1 there where some other problems :-While the player is falling and the jump button is not pressed the player stay standing or when the player move right or left the player run while he is falling.
So to fix these problems we will start first by making two new sprite :
-sprPlayerFalling.
-sprPlayerJumpMove.
Then we have to add a new variable to indicate if the player is falling or not :
Create event:
falling = false;
Step event :
And then we will go to step mode and change somthing :
We have already this code :
if place_free(x,y+1){
gravity = 0.5;
}else{
gravity = 0;
}
we will add some codes:
if place_free(x,y+1){
gravity = 0.5;
falling = true;
}else{
gravity = 0;
falling = false;
}
The variable falling will return true if player is falling and false if it is not.
Then add this code in step event :
if falling && !keyboard_check(vk_up){
sprite_index = sprPlayerFalling;
}
This code will check if the player is falling (falling = true) and the up key is not pressed then the sprite of the player will change to the falling sprite.
If you test the game now there should be a collision bug when the player jump and when he touch the ground when he try to move the sprite change to the falling sprite and not the running one.
You have to change the player's mask, there are too many way you can make a rectangle and assign it or assign the Idle sprite so that the whole object will have the same collision shap :
Here i have choose the Idle Player sprite.
Now the bug is fixed, let's continue.
We have now to set the sprite of the player moving when it is falling, we have to go to the step event:
At this part of the code that we have just to write :
if falling && !keyboard_check(vk_up){
sprite_index = sprPlayerFalling;
}
We have to add some instructions :
if falling && !keyboard_check(vk_up){
if (keyboard_check(vk_right)) or (keyboard_check(vk_left)){
sprite_index = sprPlayerJumpMove;
}else{
sprite_index = sprPlayerFalling;
}
}
This will check if the right or the left while falling if true the sprite will be the sprPlayerJumpMove if not the sprite will be sprPlayerFalling.
Congratulation, you have made a complete platformer game with GameMaker you can check other tutorials for making ennemies or other.
Comments
Post a Comment