|
|
@ -6,6 +6,10 @@ class Player {
|
|
|
|
this.image = random(Images.players);
|
|
|
|
this.image = random(Images.players);
|
|
|
|
this.width = options.width || 64;
|
|
|
|
this.width = options.width || 64;
|
|
|
|
this.height = options.height || 64;
|
|
|
|
this.height = options.height || 64;
|
|
|
|
|
|
|
|
this.hitbox = {
|
|
|
|
|
|
|
|
width: this.width * 0.6,
|
|
|
|
|
|
|
|
height: this.height * 0.6,
|
|
|
|
|
|
|
|
};
|
|
|
|
this.burgers = 5;
|
|
|
|
this.burgers = 5;
|
|
|
|
this.maxBurgers = 12;
|
|
|
|
this.maxBurgers = 12;
|
|
|
|
this.moneys = 0;
|
|
|
|
this.moneys = 0;
|
|
|
@ -22,14 +26,14 @@ class Player {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
draw() {
|
|
|
|
draw() {
|
|
|
|
let corner = {
|
|
|
|
|
|
|
|
x: this.position.x - this.width*0.5,
|
|
|
|
|
|
|
|
y: this.position.y - this.height*0.5
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let half = {
|
|
|
|
let half = {
|
|
|
|
width: this.width * 0.5,
|
|
|
|
width: this.width * 0.5,
|
|
|
|
height: this.height * 0.5,
|
|
|
|
height: this.height * 0.5,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
let corner = {
|
|
|
|
|
|
|
|
x: this.position.x - half.width,
|
|
|
|
|
|
|
|
y: this.position.y - half.height,
|
|
|
|
|
|
|
|
};
|
|
|
|
tint(Colors.Purple);
|
|
|
|
tint(Colors.Purple);
|
|
|
|
image(this.image, corner.x, corner.y, this.width, this.height);
|
|
|
|
image(this.image, corner.x, corner.y, this.width, this.height);
|
|
|
|
|
|
|
|
|
|
|
@ -43,41 +47,59 @@ class Player {
|
|
|
|
|
|
|
|
|
|
|
|
strokeWeight(1);
|
|
|
|
strokeWeight(1);
|
|
|
|
noFill();
|
|
|
|
noFill();
|
|
|
|
rect(corner.x, corner.y, this.width, this.height);
|
|
|
|
|
|
|
|
|
|
|
|
rect(this.position.x - this.hitbox.width * 0.5,
|
|
|
|
|
|
|
|
this.position.y - this.hitbox.height * 0.5,
|
|
|
|
|
|
|
|
this.hitbox.width,
|
|
|
|
|
|
|
|
this.hitbox.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drawBurgerMeter() {
|
|
|
|
drawBurgerMeter() {
|
|
|
|
let half = {width: this.width*0.5, height: this.height*0.5};
|
|
|
|
let half = {width: this.width*0.5, height: this.height*0.5};
|
|
|
|
let w = this.width;
|
|
|
|
let box = {
|
|
|
|
let h = this.height * 0.2;
|
|
|
|
w: 64,
|
|
|
|
let x = this.position.x - half.width;
|
|
|
|
h: 12,
|
|
|
|
let y = this.position.y + half.height + this.height * 0.1;
|
|
|
|
x: this.position.x - half.width,
|
|
|
|
let cellWidth = w / this.maxBurgers;
|
|
|
|
y: this.position.y + half.height,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stroke(Colors.Purple);
|
|
|
|
stroke(Colors.Purple);
|
|
|
|
strokeWeight(1);
|
|
|
|
strokeWeight(1);
|
|
|
|
noFill();
|
|
|
|
noFill();
|
|
|
|
rect(x, y, w, h, 4);
|
|
|
|
rect(box.x, box.y, box.w, box.h, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cellWidth = (box.w-8) / this.maxBurgers;
|
|
|
|
|
|
|
|
|
|
|
|
noStroke();
|
|
|
|
noStroke();
|
|
|
|
fill(Colors.Purple);
|
|
|
|
fill(Colors.Purple);
|
|
|
|
for (let i = 0; i < this.burgers; i++) {
|
|
|
|
for (let i = 0; i < this.burgers; i++) {
|
|
|
|
let cellX = x + i * cellWidth;
|
|
|
|
let cellX = box.x + 4 + i * cellWidth;
|
|
|
|
rect(cellX + cellWidth * 0.1, y + h*0.1, cellWidth*0.8, h*0.8);
|
|
|
|
rect(cellX, box.y+2, cellWidth-1, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drawMoneyMeter() {
|
|
|
|
drawMoneyMeter() {
|
|
|
|
|
|
|
|
let half = {width: this.width*0.5, height: this.height*0.5};
|
|
|
|
|
|
|
|
let box = {
|
|
|
|
|
|
|
|
w: 64,
|
|
|
|
|
|
|
|
h: 12,
|
|
|
|
|
|
|
|
x: this.position.x - half.width,
|
|
|
|
|
|
|
|
y: this.position.y + half.height + 14,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stroke(Colors.DarkGreen);
|
|
|
|
|
|
|
|
strokeWeight(1);
|
|
|
|
|
|
|
|
noFill();
|
|
|
|
|
|
|
|
rect(box.x, box.y, box.w, box.h, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cellWidth = (box.w-8) / this.maxMoneys;
|
|
|
|
|
|
|
|
|
|
|
|
noStroke();
|
|
|
|
noStroke();
|
|
|
|
fill(Colors.DarkGreen);
|
|
|
|
fill(Colors.DarkGreen);
|
|
|
|
let meterWidth = this.width;
|
|
|
|
|
|
|
|
let meterHeight = this.height * 0.2;
|
|
|
|
|
|
|
|
let cellWidth = meterWidth / this.maxMoneys;
|
|
|
|
|
|
|
|
for (let i = 0; i < this.moneys; i++) {
|
|
|
|
for (let i = 0; i < this.moneys; i++) {
|
|
|
|
let x = this.position.x - this.width * 0.5 + i * cellWidth;
|
|
|
|
let cellX = box.x + 4 + i * cellWidth;
|
|
|
|
let y = this.position.y + this.height * 0.5 + 30;
|
|
|
|
rect(cellX, box.y+2, cellWidth-1, 8);
|
|
|
|
rect(x + cellWidth * 0.1, y, cellWidth*0.8, 10);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|