From f5952f30eb7b237012842aefecc98975de17b4f2 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Mon, 25 Nov 2024 14:14:20 -0500 Subject: [PATCH] test --- js/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 13febef..f61ed2c 100644 --- a/js/index.js +++ b/js/index.js @@ -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();