test
This commit is contained in:
parent
db39fb66e0
commit
f5952f30eb
1 changed files with 12 additions and 2 deletions
12
js/index.js
12
js/index.js
|
@ -21,6 +21,8 @@ function Game() {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.vel = vel;
|
this.vel = vel;
|
||||||
this.rot = 0;
|
this.rot = 0;
|
||||||
|
this.dir = 1;
|
||||||
|
this.ticks = 1;
|
||||||
this.assetsIn = {
|
this.assetsIn = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -38,9 +40,11 @@ Game.prototype.main = function () {
|
||||||
this.vel.x *= 0.9;
|
this.vel.x *= 0.9;
|
||||||
this.vel.y *= 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.rot = this.rot % (Math.PI * 10);
|
||||||
|
|
||||||
|
this.ticks++;
|
||||||
|
|
||||||
this.camera.x = -this.pos.x * 0.1 + this.camera.x * 0.9;
|
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;
|
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 () {
|
Game.prototype.click = function () {
|
||||||
let { rot } = this;
|
let { rot } = this;
|
||||||
|
|
||||||
|
if (this.ticks < 10) {
|
||||||
|
this.dir *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
this.vel.x += Math.sin(rot) * 25;
|
this.vel.x += Math.sin(rot) * 25;
|
||||||
this.vel.y -= Math.cos(rot) * 25;
|
this.vel.y -= Math.cos(rot) * 25;
|
||||||
|
|
||||||
|
this.ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var game = new Game();
|
var game = new Game();
|
||||||
|
|
Loading…
Reference in a new issue