You are viewing our Forum Archives. To view or take place in current topics click here.
Does any one here make games with game maker
Posted:

Does any one here make games with game makerPosted:

Baz_Accents
  • Blind Luck
Status: Offline
Joined: May 09, 201113Year Member
Posts: 1,467
Reputation Power: 62
Status: Offline
Joined: May 09, 201113Year Member
Posts: 1,467
Reputation Power: 62
i kinda need help with my game i fall through the ground if i stay still for about 3 seconds and i cant move without jumping
here's my create code for my character
(vsp = 0;
hsp = 0;
grav = 0.5;
grounded = 0;)
and heres my step code (//get  our inputs
key_Left  =  keyboard_check_direct(vk_left);
key_Right  =  keyboard_check_direct(vk_right);
key_up  =  keyboard_check_direct(vk_up);

//Move left and right
if (key_Left)
{
     hsp = -2;
     image_xscale = -1;
}

if (key_Right)
{
     hsp = 2;
     image_xscale = 1;
}

//Neutral input = 0 movement
if ((key_Right && key_Left) or (!key_Right && !key_Left))
{
     hsp = 0;
}

//jumping
if (key_up)
{
     if (grounded) vsp = -7;
}

vsp+= grav;

//vertical collision
if place_meeting(x,y+vsp,par_wall)
{
     while (!place_meeting(x,y+1,par_wall)) y+=1;
     vsp = 0;
     grounded = 1;
}
else
{
     grounded = 1;
}


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

//commit to movement
x += hsp;
y += vsp;)

and heres a vid of me playing i havent added much in and the vid lags a bit

if you can help please tell me and i will rep


Last edited by Baz_Accents ; edited 1 time in total
#2. Posted:
tc4waza
  • Powerhouse
Status: Offline
Joined: Mar 21, 200915Year Member
Posts: 471
Reputation Power: 20
Status: Offline
Joined: Mar 21, 200915Year Member
Posts: 471
Reputation Power: 20
I am not familiarized with game maker code, but with other. So I will try to offer some help so you may resolve the problem. If the player is only able to move while jumping, it has something to do with the vertical collision. It is making your player grounded to a specific spot regardless if left_key or right_key is pressed, but jumping its free flying, therefore allowing you to move. Hope this helps
#3. Posted:
UnrealEgg
  • Powerhouse
Status: Offline
Joined: May 30, 201014Year Member
Posts: 438
Reputation Power: 49
Status: Offline
Joined: May 30, 201014Year Member
Posts: 438
Reputation Power: 49
I haven't had any experience with game maker either however, I think I may have spotted the issue.


while (!place_meeting(x,y+1,par_wall)) y+=1;
vsp = 0;
grounded = 1;
}


To me, this looks like you may be adding onto the y in the wrong direction? Is (0,0) the top left? If so, you want to do y-= 1;

However, doing this would also result in a problem of getting stuck in the ceiling (possibly) but your gravity may prevent that.

A better way would be to keep track of the player's previous (X,Y) and if there's a collision, set it back to the last Y. This would work for both directions.
#4. Posted:
Baz_Accents
  • Blind Luck
Status: Offline
Joined: May 09, 201113Year Member
Posts: 1,467
Reputation Power: 62
Status: Offline
Joined: May 09, 201113Year Member
Posts: 1,467
Reputation Power: 62
i found the problem on vertical collision i had
//vertical collision
if place_meeting(x,y+vsp,par_wall)
{
     while (!place_meeting(x,y+1,par_wall)) y+=1;
     vsp = 0;
     grounded = 1;
}
else
{

but now i changed it too
//vertical collision
if place_meeting(x,y+vsp,par_wall)
{
     while (!place_meeting(x,y+sign(vsp),par_wall)) y+=sign(vsp);
     if  (sign(vsp) == 1) grounded = 1;
     vsp = 0;
}
else
{
     grounded = 0;
}

vid of it working better
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.