Windows (literally fourth game) Can't make the character walljump in Metroid Fan Game

elec

Member
So, this is literally my fourth game ever, and i want to make a metroid fangame. I followed a basic tutorial, and changed the controls to make it feel like Super Metroid (gravity, Gamepad, Jump height, etc) and i don't know how to make a WallJump (on the same wall)
Help?

{
platform_collisions_step(wall);

if(place_free(x,y+1)){
gravity = .6;
} else {
gravity = 0;
}

if(keyboard_check(vk_right)&& place_free(x+1,y)) {
hspeed = 5;
}

if(keyboard_check(vk_left)&& place_free(x-1,y)){
hspeed = -5;
}

if(!keyboard_check(vk_left) && !keyboard_check(vk_right)){
platform_friction(true,1)
}else{
platform_friction(false,1)
}

if(keyboard_check(ord("2")) && !place_free(x,y+1)&& place_free(x,y-1))
vspeed = -12;
}
 

Joe Ellis

Member
You could make it so while the player is in mid air, if you collide with a wall, latch onto it, then set a certain time you can hold onto it, if you press jump, you'll jump sideways off the wall, and if not when the time is up you'll fall off.

I recommend converting your player object into a state machine for this, as the wall jumping part is a separate state that the player will be in while it's doing it, and pretty much all the code that's normally run won't apply while he's latched onto a wall.
It essentially makes the player object's step event be:
Code:
script_execute(state)
Some common processes can be put into the step event around this, like if gravity or things for handling the animation frames are always the same
But this makes it alot easier to deal with complex things that should only happen when the player is doing a certain thing.

For instance, if you didn't use states, you would have to use several if's\else's containing large amounts of code, which would all contain very similar lines to each other with small changes, which can get really hard\awkward to work with when it's all in one script. With states you work with nice small scripts with the specific things that can happen while the player is doing a certain thing, eg. swimming, climbing up a ladder, crouching, crawling etc.
 

elec

Member
You could make it so while the player is in mid air, if you collide with a wall, latch onto it, then set a certain time you can hold onto it, if you press jump, you'll jump sideways off the wall, and if not when the time is up you'll fall off.

I recommend converting your player object into a state machine for this, as the wall jumping part is a separate state that the player will be in while it's doing it, and pretty much all the code that's normally run won't apply while he's latched onto a wall.
It essentially makes the player object's step event be:
Code:
script_execute(state)
Some common processes can be put into the step event around this, like if gravity or things for handling the animation frames are always the same
But this makes it alot easier to deal with complex things that should only happen when the player is doing a certain thing.

For instance, if you didn't use states, you would have to use several if's\else's containing large amounts of code, which would all contain very similar lines to each other with small changes, which can get really hard\awkward to work with when it's all in one script. With states you work with nice small scripts with the specific things that can happen while the player is doing a certain thing, eg. swimming, climbing up a ladder, crouching, crawling etc.
Thanks! Gonna research more into states!
 
Last edited:

samspade

Member
Some of the most basic state machines I've seen are based in large part on the switch statement. I believe that @samspade has a video on that (?)
That's true. It's this one. :)


However, for state machines, I think this is my favorite tutorial:


She uses a normal if, else if, chain and then switches it to scripts (I personally don't like script only because you end up with literally hundreds if not thousands of scripts if you have a lot of enemies and so on which becomes a nightmare to deal with and take from one project to another. Once methods are introduced in 2.3 I think it's probably going to be the way to go though.)
 
Top