I'm building an arcade game with plain javascript. I built bricks using images and not with canvas, I want to build a function that stops the character from moving also I want him to be able to jump over the objects, and if the character is on top of one of the bricks I want him to not dropdown.
I built an interval that checks that character top && left and also the bricks' left (still haven't built the top )
also each time I placed a brick in the level I also inserted them in an array that I could refer to them in a loop later.
**here's the code: **
if (
characterLeft >= 1000 ||
(characterLeft >= BrickLeftArray[b] - 160 &&
characterLeft <= BrickLeftArray[b] + 80)
) {
/*|| characterLeft == BrickLeftArray[b] - 100)*/
clearInterval(IntervalMoveRight);
flagfortherunning = false;
}
notes**
clear interval move right clears the interval of the character from moving.
flagfortheruning
is a flag that if it's true the moving function is on.
if there's a need to load more code please say.