You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: scripts/logic/compass.js
+2-1
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ function updateCompass() {//A function designed to update the compass.
18
18
vardistance=0;//A variable to hold the distance to a point.
19
19
if((compassPoint.x===0&&compassPoint.y===0)===false){//If the compass point isn't set at origin.
20
20
compassPoint.distance=Math.floor(Math.sqrt(Math.pow(currentPlayer.x-compassPoint.x,2)+Math.pow(currentPlayer.y-compassPoint.y,2)));//Use the distance formula to calculate distance to the point.
21
-
if(distance<=currentPlayer.stepSize){//If the distance is less then the player's step size.
21
+
console.log("THIS WORKS");
22
+
if(compassPoint.distance<=currentPlayer.stepSize){//If the distance is less then the player's step size.
22
23
compassPoint.x=0;//Set the compass point to origin so the compass objective no longer shows on the player's compass.
23
24
compassPoint.y=0;
24
25
}else{//If the distance is greater than the player's step size.
Copy file name to clipboardexpand all lines: scripts/logic/game.js
+6-6
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,12 @@ function getCoordinatesOfClick(event) {//A function to get coordinates on the ca
9
9
currentPlayer.angle=findAngleBetweenTwoPoints(x,y);//Set the angle of where the current player is facing to the angle between the click and the player coordinate.
10
10
}
11
11
12
-
functionlogicLoop(){//A logic loop to do the logic of the game.
12
+
functiongameLoop(){//A logic loop to do the logic of the game.
13
13
"use strict";
14
-
if(connected){//If the client is connected to the web socket server.
15
-
updatePlayerInformation();//Update the player object information on the server.
16
-
}
14
+
drawingContext.fillStyle="black";//Set the colour of what to draw to black.
15
+
drawingContext.fillRect(0,0,800,400);//Fill the canvas with black.
16
+
drawPlayers();//Draw all of the players.
17
+
drawGUI();//Draw the GUI.
17
18
updateCompass();//Update the compass.
18
19
if(currentPlayer.aiControlled&&(compassPoint.x===0&&compassPoint.y===0)===false){//If the current player is AI controlled and they have an objective.
19
20
currentPlayer.angle=findAngleBetweenTwoPoints(compassPoint.x,compassPoint.y);//Set the current player's angle towards the compass.
0 commit comments