implement player class with player movement

This commit is contained in:
Thorsten Rausch
2021-06-15 18:18:16 +02:00
parent 2ac1733251
commit c243138b87
4 changed files with 41 additions and 55 deletions

View File

@@ -5,12 +5,6 @@
dice.svg: https://www.svgrepo.com/download/198836/gambler-casino.svg
sprite.jpg: https://media.istockphoto.com/photos/gray-granite-stone-texture-seamless-square-background-tile-ready-picture-id1096464726
*/
let curr_player = 1;
let player_array = createPlayers(4);
let player_color = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00];
let player_sprite_array = [];
let hunter = new Hunter();
let card;
let answer = null;
let show_card = false;

View File

@@ -1,39 +0,0 @@
function createPlayers(amount) {
let players = new Array(amount);
for (let i = 0; i < amount; i++) {
players[i] = new Player();
}
return players;
}
class Player {
constructor() {
this.position = 0;
this.alive = true;
}
move(amount) {
this.position += amount;
if (this.position === 15) {
// todo: win
}
}
}
class Hunter {
constructor() {
this.position = 0;
}
move(amount) {
this.position += amount;
}
hunt(players) {
for (let i = 0; i < players.length; i++) {
if (players[i].position <= this.position) {
players[i].alive = false;
}
}
}
}