xxxxxxxxxx
67
class player {
constructor (p, n, s, k, d, a, c) {
this.player = p
this.name = n
this.cs = s
this.kills = k
this.deaths = d
this.assists = a
this.colour = c
this.pos = {
x: 0,
y: height / 6
}
}
// draws the ellipse
draw () {
// this.colour was chosen based on individuals favourite colour
fill(this.colour)
// image size was based on the players amount of kills (multiplied by 1.5 to make the difference easier to see)
fill(this.colour)
ellipse(this.pos.x, this.pos.y * this.player, this.kills * 1.5)
}
move () {
this.pos.x = this.pos.x + (this.cs / 2000)
if (this.pos.x > width + this.kills) {
this.pos.x = this.kills * -1
}
}
}
// array is created to load player stats
const players = []
function setup() {
createCanvas(800, 400);
// individual player scoreboards was added to the "players" array
// game 1
players.push (new player (1, 'NATHAN', 7000, 25, 30, 8, "#AEF359"))
players.push (new player (2, 'JOHNNY', 10000, 37, 23, 6, "#FFFF00"))
players.push (new player (3, 'CECE', 6000, 20, 30, 9, "#89CFF0"))
players.push (new player (4, 'RUBEN', 12000, 40, 29, 10, "#E39FF6"))
players.push (new player (5, 'LUCAS', 5000, 17, 27, 8, "#FFFFFF"))
console.log (players)
}
function draw() {
// helps create the trail effect
fill (0, 12)
rect (0, 0, 1600, 800)
fill(255)
noStroke()
// completes each function within the constructor on each player included in the array
players.forEach ((p, i) => {
p.draw ()
p.move ()
})
}