We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello community, I'm a student and I have to do a final project of processing, so I decided to make an RPG Scene. I have a lot of problems and bugs (for example I don't know how to do a movement animation of the character) but I mainly want to fix the problem of the objects. I have an image (the main character) that moves with keys, and I have a cow that interacts with the character, but it doesn't make contact with the character. Here you have the sketch: https://www.openprocessing.org/sketch/471627
Answers
For movement, see keyIsDown(): https://p5js.org/reference/#/p5/keyIsDown
But for developing your RPG, you're much better off learning OOP using classes: ~O)
https://Developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor
For collision look at dist() and if in the reference
For approaches to collision detection in general, see:
You could handle cases like this with
dist()
, or you could handle them with simple rect/rect collision detection. For something like a chest of treasure or a building you might find that to give more intuitive results.