You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

2 years ago
"use strict"
class Map{
constructor(w, h){
let x = width - w - 20;
let y = height - h - 20;
this.pos = createVector(x, y);
this.dim = createVector(w, h);
this.bricks = [];
}
display(player, goal, world){
this.show(player, goal, world);
}
show(player, goal, world){
let x = width - this.dim.x - 20;
let y = height - this.dim.y - 20;
this.pos = createVector(x, y);
fill(colors.map.background.fill);
stroke(colors.map.background.stroke);
strokeWeight(10);
rect(this.pos.x, this.pos.y, this.dim.x, this.dim.y, this.dim.x * 0.05);
let goalX = map(goal.pos.x, 0, world.dim.x, this.pos.x + 10, this.pos.x + this.dim.x - 10),
goalY = map(goal.pos.y, 0, world.dim.y, this.pos.y + 10, this.pos.y + this.dim.y - 10);
stroke(colors.goal.main);
point(goalX, goalY);
let playerX = map(player.pos.x, 0, world.dim.x, this.pos.x + 10, this.pos.x + this.dim.x - 10),
playerY = map(player.pos.y, 0, world.dim.y, this.pos.y + 10, this.pos.y + this.dim.y - 10);
stroke(player.color);
point(playerX, playerY);
let flagH = 30,
flagW = 15;
stroke(0);
strokeWeight(2);
line(goalX, goalY, goalX, goalY - flagH);
fill(255, 0, 0);
rect(goalX, goalY - flagH + 2, flagW, flagH * 0.3);
}
}