¿Alguien sabe por qué este fragmento de código no funciona? Estoy usando bibliotecas p5 como p5.play, p5.js.p5.sound, p5dominm o algo así. Aquí está la pieza de código:
class Player{ constructor(){ this.x, this.y, this.width, this.height } if(keyPressed(d)) { player.x=player.x+6; distance=distance+0.5 }}
Después de crear una clase, debe crear una instancia de la clase. Prueba de esta manera:
class Player{ constructor(){ this.x, this.y, this.width, this.height } const player = new Player(); if(keyPressed(d)) { player.x=player.x+6; distance=distance+0.5 }