clustering
This commit is contained in:
parent
c210200bbe
commit
b6ffe5cf32
2 changed files with 42 additions and 25 deletions
19
js/player.js
19
js/player.js
|
@ -1,5 +1,5 @@
|
|||
function Player() {
|
||||
let pos = { x: Math.random() * 1000 - 50, y: Math.random() * 1000 - 50 };
|
||||
let pos = { x: Math.random() * 5000 - 50, y: Math.random() * 5000 - 50 };
|
||||
let camera = { x: -pos.x, y: -pos.y };
|
||||
let vel = { x: 0, y: 0 };
|
||||
|
||||
|
@ -8,4 +8,21 @@ function Player() {
|
|||
this.vel = vel;
|
||||
this.rot = 0;
|
||||
this.dir = 1;
|
||||
this.ticks = 0;
|
||||
}
|
||||
|
||||
Player.prototype.bump = function () {
|
||||
let player = this;
|
||||
|
||||
if (player.ticks < 10) {
|
||||
player.dir *= -1;
|
||||
}
|
||||
|
||||
player.vel.x *= 0.6;
|
||||
player.vel.y *= 0.6;
|
||||
|
||||
player.vel.x += Math.sin(player.rot) * 25;
|
||||
player.vel.y -= Math.cos(player.rot) * 25;
|
||||
|
||||
player.ticks = 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue