Loading...
131
8 months ago

Game Maker Studio: Platformer tutorial!


Here's the code!

Create event:

/// Create event

// Main

hsp = 0 // Horisontal speed

vsp = 0 // Vertical speed

// Physics

grav = 0.3 // Gravity

move_sp = 5 // Move speed

jump_f = 10 // Jump force

Step event:

/// Step event

// Keys imput

right_k = keyboard_check(ord("D")) // Right key imput

left_k = keyboard_check(ord("A")) // Left key imput

jump_k = keyboard_check_pressed(vk_space) // Jump key imput

// Physic and else

move = right_k - left_k // Move imput

hsp = move * move_sp // Walk physic imput

vsp += grav // Gravity physic imput

// Jump logic

if (place_meeting(x,y+1,obj_solid)) and (jump_k) // If player pressed the jump button on the ground

{

vsp -= jump_f // Jump system logic

}

// Collisions

// Horisontal collision

if (place_meeting(x+hsp,y,obj_solid)) // Collision with ground

{

while (!place_meeting(x+sign(hsp),y,obj_solid)) // If there wasn't any collison

{

x += sign(hsp) // Player can move

}

hsp = 0 // Player can't move

}

// Vertical collision

if (place_meeting(x,y+vsp,obj_solid)) // Collision with ground

{

while (!place_meeting(x,y+sign(vsp),obj_solid)) // If there wasn't any collison

{

y += sign(vsp) // Player can move

}

vsp = 0 // Player can't move

}

// X and Y imput

x += hsp

y += vsp



4 comments

Loading...

Next up

After messing around with OpenGL i finally drew up a square.

New Plumber of All Seasons!

Fan art for @Mrc_pizzapop_97 !

So, i have added texture batching, and now my fps flew up to 150 (max), and i think i'll also add texture atlases render, to have a simple sprite sheet with sprites in it.

Happy #WIPWednesday! Are you working on a game? Making some art? Practicing a song? Something else? Tell us in the comments!

А теперь думайте кому это адресованно.

Happy #WIPWednesday! Are you working on a game? Making some art? Practicing a song? Something else? Tell us in the comments!

Вот вам тысяча чёрных кубиков, которые я отрисовал с помощью Render Batching.

Зачем?

Ох блять, если бы не over дохуя времени, я бы это не сделал.

Я уже думал забить на проект, но резко был переубеждён самим собой.

A new quest celebrating Dead Pets Unleashed just entered your quest log!

Dead Pets Unleashed is a rock feminist adventure where you play as a demon named Gordy (the bassist of the punk band Dead Pets.)

Play the #DeadPetsDemo now: https://bit.ly/deadpetsgj

Vasia the cat.