0

im remaking the game "outlaw" in p5.js with the library p5.play, the problem is that whenever i try using the functions:collided and collides. it dosnt work, heres the piece of code that dosnt seem to be working:

  if(player1.collided(bullet2)){
    hp1=hp1-1
  }

Ive tried changing the order of the variables, like checking the collision of the bullet with the player and the other way around, still it isnt working.

  • you need to post your definition of `player1` and `bullet2`. Are you sure the condition is not triggered? you should put a console.log() inside to be sure it's not triggering. – Sembei Norimaki Jul 13 '23 at 08:55

1 Answers1

0

You didn't really provide enough information about your program for anyone to give an answer.

But, my guess is that you need to put that if statement which checks for collisions in the p5.js draw loop instead of setup.

quinton-ashley
  • 133
  • 2
  • 10