Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Player [ Create ] code

/// @description Set Player variables
vsp = 0;   // Vertical Speed
hsp = 0;   // Horizontal Speed
grv = 0.3;  // Gravity
walksp = 4;   // Walk Speed
jumpsp = 9;   // Jump Speed

Player [ STEP ] code for basic gravity and LEFT<>RIGHT movement

/// @description Player Collision with walls
// Assign direction variables
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
// Moving
var _move = key_right - key_left ;
hsp = _move * walksp;
vsp = vsp + grv;
// Horizontal  Collision
if (place_meeting(x+hsp, y, oWall))
   {
   while (!place_meeting(x+sign(hsp),y,oWall))
       {
           x = x + sign(hsp);
       }
       hsp = 0;
   
   }
x = x + hsp;
   
// Vertical Collision   
if (place_meeting(x, y+vsp, oWall))
   {
   while (!place_meeting(x,y+sign(vsp),oWall))
       {
           y = y + sign(vsp);
       }
       vsp = 0;
   }
y = y + vsp;