Hello guys I am not sure if this is the correct thing to be asking but here I go: So first off here is my code
public static void block(SpriteBatch batch, float blockX) {
batch.draw(Assets.stoneShort, movement + blockX, 80);
// collision detection
/*these seemingly random numbers are just here for collision detection there the boundaries necessary to get this to work*/
if (movement + blockX <= 165 && personY <= 160 && !(80 > movement + blockX + 103)) {
if (movement + blockX <= 165 && !(movement + blockX <= 163) && personY <= 130)
move = false;
else
move = true;
if (move == true && personY > 134) {
floor = 135;
jump = false;
}
} else
floor = 80;
}
If I call this method only once everything works great collision detection is perfect and everything works. It gets messy when I call it more then once. So what I believe the problem is, is that the else{ floor = 80}; is overriding the if (move == true…){ floor = 135…} Since this is a sidescroller and if i call this method by
Objects.block(batch, 1000);
Objects.block(batch, 1500);
(Floor defines the Y value that the player stands on 0,0 starts at bottom left and goes up)
The first one has no collision detection on the top which is because of the problem i had just said about 80 overriding the 135, but on the second block (with the coordinates of 1500) the collision detection works great, so this further leads me to believe that ^^^ is the problem. So is this possible to make one number overide the other? or is there something wrong with my code