What's new
Roleplay UK

Join the UK's biggest roleplay community on FiveM and experience endless new roleplay opportunities!

New to coding, need help :D

CyberDOLT

Digital Hobo
So as you can tell from the title I am new to the world of coding, but I hope that I can easily learn code. I've recently (Well a month ago) picked up Game Maker Studio to try and make simplistic games (need to start somewhere). I've tried the best to my abilities, but I done diddely fucked up. 

My "Obj_player" doesn't wanna move and I am having trouble finding out why (I'm so bad basically). So.. here is my code



Variables :

 

/// Variables

grav = 1;
movespeed = 10;
vsp = 0; 
hsp = 0;
fric = 1;

^ This code executes as soon as the object is created.

 

Main Code :

/// Movement bby

// Player Inputs

rkey = keyboard_check(ord("D"))
lkey = keyboard_check(ord("A"))
jkey = keyboard_check_pressed (ord("W"))
jkey = keyboard_check_pressed (vk_space)


// Making sure the Ground is the Ground
if (place_meeting(x,y+1,obj_block))
    {
        vsp = 0;
            } else {
                    if(vsp > 5) { 
                        vsp += grav;    }}
                        


// Jump code
if(keyboard_check_pressed(ord("W")) && vsp < -4){ vsp = -4; }         
if(keyboard_check_pressed(vk_space) && vsp < -4){ vsp = -4; }             


// Moving Left
if(lkey) {
    if(hsp > -movespeed) {
        hsp -= fric; }}
        


// Moving Right'
if(rkey) {
    if(hsp > movespeed) {
        hsp += fric}}                           


^This executes every frame 

 
Back
Top