This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent db39fb66e0
commit f5952f30eb

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;
}
@ -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();