Skip to content

Commit 15c7d79

Browse files
Added camera and display information about players.
1 parent b78ec6e commit 15c7d79

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/drawing/camera.js

+7
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,12 @@ function drawPlayers() {//A function to draw all of the players.
1919
}
2020
drawingContext.fillStyle = players[i].color;//Set the colour of what to draw to the player's colour.
2121
drawingContext.fillRect(cameraXCoord, cameraYCoord, players[i].width, players[i].height);//Draw the player at the X and Y coordinate.
22+
drawingContext.fillStyle = "red";//Set the colour of what to draw to red.
23+
drawingContext.fillRect(cameraXCoord - 15, cameraYCoord - 10, 50, 5);//Draw a red health bar representing the player's health.
24+
drawingContext.fillStyle = "green";//Set the colour of what to draw to green.
25+
drawingContext.fillRect(cameraXCoord - 15, cameraYCoord - 10, (50 / currentPlayer.maxHealth) * currentPlayer.health, 5);//Draw a green health bar representing the percentage of the health.
26+
drawingContext.font = "10px Arial";//Set the font of what to draw.
27+
drawingContext.fillStyle = "white";//Set the colour of what to draw.
28+
drawingContext.fillText(players[i].name, cameraXCoord - 15, cameraYCoord - 15);//Draw the player's name above their head.
2229
}
2330
}

0 commit comments

Comments
 (0)