getalobi.blogg.se

Gamemaker studio 2 platformer tutorial
Gamemaker studio 2 platformer tutorial







What has changed? Yes, there is one more condition, after the and. If (keyboard_check(vk_right) and place_free(x + 3, y)) hspeed = 3 If (keyboard_check(vk_left) and place_free(x – 3, y)) hspeed = -3 So, we’re putting a condition (using “if ()”) and then changing hspeed if the condition turns out true. But if the right key too is not pressed, it just changes hspeed to 0, causing the player to stop. If left key is not pressed, as an alternative it checks for the right key and turns hspeed to 3 so the player moves to the right. It checks if we’ve pressed the left key, then changes hspeed to -3, so the object moves to the left. If on keyboard right key is pressed, set horizontal speed to 3. Hey, if on keyboard left key is pressed, set horizontal speed to -3. Keyboard_check() is used to check if a key is being pressed on the keyboard, and hspeed is the horizontal movement speed of the object. If you’re not familiar with coding, this might seem a bit confusing.

gamemaker studio 2 platformer tutorial

If (keyboard_check(vk_right)) hspeed = 3 If (keyboard_check(vk_left)) hspeed = -3

#GAMEMAKER STUDIO 2 PLATFORMER TUTORIAL CODE#

Before adding any code in there, take a look at this piece of code. This will stop the player from falling (due to gravity) when it collides with the block object, by turning its vertical speed (vspeed) to 0. So now our player object has gravity and will stick to the ground (as long as it is there).Īdd a collision with obj_block event and add this code:

gamemaker studio 2 platformer tutorial

Add an Execute Code action from the control drop-down menu. Open your obj_player and add the Create event. Place the objects in a room and make a level. When you create the obj_block, tick the Solid option. One will be spr_player (for the player) and the other spr_block (which will act as the walls/floor).

gamemaker studio 2 platformer tutorial

This is for beginners who want to learn GML. Hey there folks! In this tutorial we’re going to create a simple platformer in GameMaker: Studio, using GML (Game Maker Language).







Gamemaker studio 2 platformer tutorial