B
Becon
Guest
So I requested help on this old project back in the original GM forum and no help but I have come back to it trying new things.
Off and on for a few years I have been trying to make a random generated endless runner using slopes. I can get the slopes to work fine on their own in many different ways. I got the level to randomly generate and sync the slopes and then move them to the left like a runner often does....On it's own.
When you put the two together though, ground moving to the left with a slope coming at the player, upon collision, the ground/solid objects/slopes whatever, they move. If I jump and land on them they shift a little. When they come for the player, instead of the player rising and falling with the slopes, he pushes those objects like a bulldozer across the screen stacking them on top of each other.
I'm not going to post the original code here because I forgot how most of that giant bunch of code works atm but recently editing Strawbry_jam's Part 2 code from https://forum.yoyogames.com/index.php?threads/generic-platformer.1090/
Found here: https://drive.google.com/file/d/0B-XGa2C_e2NSNTd5cjZ6aFp3RTQ/view?usp=sharing
I was able to do get it to do what mine does, granted I just made the controls move the ground instead of the player.
obj_player
Step:
End Step:
Then I added a step even in the slopes and ground so I could force the ground to move with the L and R arrow keys instead of the player. FYI Up arrow makes player jump still so you can see that crash as well.
Step:
Any help would be greatly appreciated. Not being able to figure this one out is why I keep stepping away from GameMaker.
Off and on for a few years I have been trying to make a random generated endless runner using slopes. I can get the slopes to work fine on their own in many different ways. I got the level to randomly generate and sync the slopes and then move them to the left like a runner often does....On it's own.
When you put the two together though, ground moving to the left with a slope coming at the player, upon collision, the ground/solid objects/slopes whatever, they move. If I jump and land on them they shift a little. When they come for the player, instead of the player rising and falling with the slopes, he pushes those objects like a bulldozer across the screen stacking them on top of each other.
I'm not going to post the original code here because I forgot how most of that giant bunch of code works atm but recently editing Strawbry_jam's Part 2 code from https://forum.yoyogames.com/index.php?threads/generic-platformer.1090/
Found here: https://drive.google.com/file/d/0B-XGa2C_e2NSNTd5cjZ6aFp3RTQ/view?usp=sharing
I was able to do get it to do what mine does, granted I just made the controls move the ground instead of the player.
obj_player
Step:
Code:
///standard platform movement
//area list to get accurate on ground readings and stuff
var colList = area_get_collision_list(obj_wall);
//update jumpThru state
update_solid(colList,270,keyboard_check(vk_down));
//check if on ground
if( place_free( x, y+1 )){
gravity = 0.8; //set gravity - we are in the air!
} else {
gravity = 0; //no need for gravity on ground
//we are on ground so we can check if we need to jump
if( keyboard_check_pressed( vk_up )){
vspeed = -12;
}
}
//reset jumpThru states
reset_solid(colList);
//clean up
ds_list_destroy(colList);
Code:
///Collision Correction
//Moving into a solid puts us back as if we never moved.
//This part allows us to move on slopes and fill the gaps.
//First check if we need to correct for collision
if( speed != 0 and x == xprevious and y == yprevious ){
//get a list of all possible wall objects to collide with
var colList = move_get_collision_list(obj_wall);
//move up first if vspeed is up
if( vspeed < 0 ){
//update jumpThru state
update_solid(colList,90,keyboard_check(vk_down));
move_contact_solid( 90, -vspeed );
}
//move over if hspeed is not 0
if( hspeed != 0 ){
//setting some temporary vars
var temp_y = y;
//update jumpThru state
update_solid(colList,90,keyboard_check(vk_down));
//move up
move_contact_solid( 90, abs( hspeed ));
update_solid(colList,90 - sign( hspeed ) * 90,keyboard_check(vk_down));
//move over
move_contact_solid( 90 - sign( hspeed ) * 90, abs( hspeed ));
update_solid(colList,270,keyboard_check(vk_down));
//move down what we moved up
if(temp_y-y != 0){
move_contact_solid( 270, temp_y-y);
}
//move down again if it puts us on ground
if( !place_free( x, y + abs( hspeed ) + 1 )){
move_contact_solid( 270, abs( hspeed ));
}
}
//move down if vspeed is down
if( vspeed > 0 ){
update_solid(colList,270,keyboard_check(vk_down));
move_contact_solid( 270, vspeed );
}
//if we are blocked then set vspeed to 0
update_solid(colList,180+90*sign(vspeed),keyboard_check(vk_down));
if( !place_free( x, y + sign( vspeed ))){
vspeed = 0;
}
//set hspeed to 0 if we can't move horizontally (we're blocked)
if( hspeed != 0 and x == xprevious ){
hspeed = 0;
}
//reset jumpThru states
reset_solid(colList);
//clean up
ds_list_destroy(colList);
}
Step:
Code:
hkey = keyboard_check( vk_right ) - keyboard_check( vk_left );
//set horizontal movement based on controls
if( hkey == 0 ){
hspeed *= 0.75; //friction
if( abs( hspeed ) < 0.5 ){ hspeed = 0; }
} else {
hspeed *= 0.75;
hspeed += 2 * sign( hkey );
}