This commit is contained in:
biglyderv 2024-09-27 17:24:30 -04:00
parent ce81e999dd
commit 8959319580
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954

View file

@ -21,6 +21,8 @@ function Game() {
this.pos = pos;
this.vel = vel;
this.rot = 0;
this.dir = 1;
this.ticks = 1;
this.assetsIn = {
};
@ -38,9 +40,11 @@ Game.prototype.main = function () {
this.vel.x *= 0.9;
this.vel.y *= 0.9;
this.rot += 0.08;
this.rot += 0.08 * this.dir;
this.rot = this.rot % (Math.PI * 10);
this.ticks++;
this.camera.x = -this.pos.x * 0.1 + this.camera.x * 0.9;
this.camera.y = -this.pos.y * 0.1 + this.camera.y * 0.9;
}
@ -53,7 +57,7 @@ Game.prototype.render = function () {
ctx.save();
ctx.translate(camera.x + cs/2, camera.y + cs/2);
ctx.translate(camera.x + cs / 2, camera.y + cs / 2);
ctx.save();
@ -71,8 +75,14 @@ Game.prototype.render = function () {
Game.prototype.click = function () {
let { rot } = this;
if (this.ticks < 10) {
this.dir *= -1;
}
this.vel.x += Math.sin(rot) * 25;
this.vel.y -= Math.cos(rot) * 25;
this.ticks = 0;
}
var game = new Game();