why would this not be working on canvas
Blockquote
class Projectile{
constuctor({position,velocity}){
this.position = position
this.velocity = velocitythis.radius = 3 } draw(){ c.beginPath() c.arc(this.position.x, this.position.y, this.radius,0,Math.PI * 2) c.fillStyle = 'yellow' c.fill() c.closePath() } update(){ this.draw() this.position.x += this.velocity.x this.position.y += this.velocity.y }
}
//player object
const player = new Player()//porjectiles array
const projectiles = [
new Projectile({
position: {
x: 300,
y: 300
},
velocity: {
x: 5,
y: 0
}
})
]
Blockquote
projectiles.forEach(projectile => {
projectile.update()
});
main.js:63 Uncaught TypeError: Cannot read properties of undefined (reading ‘x’)