• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Player not moving

M

Michael Franklin

Guest
My character does not move when I run the program. I only have a step event:
Code:
//input
left = keyboard_check(ord("A"));
right = keyboard_check(ord("D"));
jump = keyboard_check_pressed(vk_space);

//Movement
var move = right - left;

hsp = move * walksp;

vsp = vsp + grv;

//Horrizontal collision
if (place_meeting(x+hsp,y,ocity)){
    
    while (!place_meeting(x+sign(hsp),y,ocity)){
        
        x = x + sign(hsp);
    }
    hsp = 0;
}
x = x + hsp;

//Verticalcollision
if (place_meeting(x,y+vsp,ocity)){
    
    while (!place_meeting(x,y+sign(vsp),ocity)){
        
        y = y + sign(vsp);
    }
    vsp = 0;
}
y = y + vsp;

//jump
if (place_meeting(x,y+1,ocity)) and (jump){
    vsp = -10;
}

if (place_meeting(x,y+1,oplat1)) and (jump){
    vsp = -10;
}

if (place_meeting(x,y+1,oplat2)) and (jump){
    vsp = -10;
}


//Animation

//jump animation

if (!place_meeting(x,y+1,ocity)){
    
    sprite_index = judyjump;
    
}

else{
    if (hsp == 0){
        sprite_index = judystand;
        
    }
        else{
        sprite_index = judyrun;
    }
}

//basic attack
if (mouse_check_button(mb_left)) sprite_index = judyattack;

//crouch
if (keyboard_check(vk_shift)){
    sprite_index = judysit;
    

}

//facing direction
if (hsp != 0) image_xscale = sign(hsp);
 

AnotherHero

Member
If you only have a step event, when are walksp and grv being set? If your character has no walksp, your speed is either (1 * 0) = 0, or (-1 * 0) = 0.
 

sinigrimi

Member
set the desired values in create event, such as hsp, grv and so on. Your player cannot take a value from a variable without a value
 
Last edited:
M

Michael Franklin

Guest
set the desired values in create event, such as hsp, grv and so on. Your player cannot take a value from a variable without a value
That's my bad. I meant that the only events I have is a step event. I already have my variables declared in the variable definition.
 
Top