Papa Doge
Member
I'm working on a proof of concept, wall climbing platformer that has some pretty basic collision checks, one of which is to check if a player is about to jump over a wall — and if he/she is — move the player sprite so that it stops at the peak instead of jumping over the peak.
The issue I'm having is that for whatever reason, my code works if I'm not storing my collision check in a variable. Even though from my perspective the results should be identical, the variable version of the collision check crashes the game.
I'll start by showcasing the two bits of code.
The code that does works...
The code that does not work...
And here are the corresponding variable definitions that I am using in both code examples...
As you can see, my variable onPeak is simply the stored version of the exact same collision check in the code that works. At this point I am happy to continue without the stored variable approach but not understanding why the second example is failing does not sit right with me.
What am I missing?
The issue I'm having is that for whatever reason, my code works if I'm not storing my collision check in a variable. Even though from my perspective the results should be identical, the variable version of the collision check crashes the game.
I'll start by showcasing the two bits of code.
The code that does works...
Code:
// if the player is scrambling up the wall and approaching the peak...
if (key_jump) && (approachingPeak) {
while (!place_meeting(x,y-1,obj_peak)) {
y -= 1;
}
}
The code that does not work...
Code:
// if the player is scrambling up the wall and approaching the peak...
if (key_jump) && (approachingPeak) {
while (!onPeak) {
y -= 1;
}
}
Code:
key_jump = keyboard_check_pressed(vk_space);
approachingPeak = place_meeting(x,y+wallScramble,obj_peak);
onPeak = place_meeting(x,y-1,obj_peak);
What am I missing?