samedi 27 avril 2019

How do I add tolerance to an if statement in Javascript

I am learning JavaScript with the p5js library and have decided to make a very basic game.

I simply want the game to end when the condition of an if statement is met. Such as

if (x == y) {
>>>endcode here<<<
}

however I need to add a tolerance of 50 to each value

so the code would be something like

if (x == y (give or take 50) ){
>>>endcode here<<<
}

I am unsure of how to add the tolerance to the statement so I have come here for some help. Thanks :)

Aucun commentaire:

Enregistrer un commentaire