I have a game sprite that I want to move verticaly, and normally this would be easy with this.x += number
, exept for the fact that the x/y of the sprite are relitive to its angle. this can be kinda confusing so I have a example here.
in other cases where the picture will not load of something else i have a link examplepicture
it can get kinda long do here is the basic code
this.update = function() {
ctx = myGameArea.context;
if (type == "image") {
ctx.save();
ctx.translate(300, 200);
ctx.rotate(this.angle);
ctx.translate(this.x, this.y)
ctx.drawImage(this.image,
this.width / -2,
this.height/ -2,
this.width, this.height);
ctx.restore();
}else {
ctx.save();
ctx.translate(this.x, this.y);
ctx.rotate(this.angle);
ctx.fillStyle = color;
ctx.fillRect(this.width / -2, this.height / -2, this.width, this.height);
ctx.restore();
}
}
function framethingupdate() {
gamething.update();
}
due to certen issues i am unable to run or provide a demo, however if the full code is needed you can find it her: full code