I'm planning to make a game using Processing. Basically I've created a character with (x, y) as his coordinates, and a 20x20 block, also with a coordinate (x1, y1). I want to keep the character from passing through the block. I've somewhat successfully figured out how to detect collision (although the numbers aren't perfect yet):
if((this.wizard.getX() < this.brickwall.getX()+10 & this.wizard.getX() > this.brickwall.getX()-10) && (this.wizard.getY() < this.brickwall.getY()+10 & this.wizard.getY() > this.brickwall.getY()-10)){
this.wizard.stop()
}
With stop being the function to stop the character. But I haven't figured out a way to make the character stop yet. I've tried something like this
this.x = this.x
this.y = this.x
whenever the stop() method is called in the wizard class, but it doesn't work. Can anyone help me?