JSFiddle - React, Tailwind, and code Playground

by raam86

JavaScript

function Bullet(x, y) {
    this.x = x;
    this.y = y;
    console.log(this.x);
}

Bullet.prototype.fire = function () {
    this.x = this.x + 1;
    console.log(this.x);
}

Bullet.prototype.draw = function (ctx, bulletImage) {
    ctx.drawImage(bulletImage, this.x, this.y);
}