-
Notifications
You must be signed in to change notification settings - Fork 0
/
Leaderboard.js
65 lines (48 loc) · 1.18 KB
/
Leaderboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class Leaderboard{
constructor(){}
getState(){
var gameStateref = database.ref('gameState')
gameStateref.on("value", function(data){
gameState = data.val()
} )
}
update(state){
database.ref('/').update({
gameState:state
})
}
async start(){
if(gameState === 0){
player = new Player();
var playerCountRef = await database.ref('playerCount').once("value");
if(playerCountRef.exists()){
playerCount = playerCountRef.val();
player.getCount();
}
fourm = new Fourm()
fourm.display();
}
}
play(){
fourm.hide();
textSize(30);
text("Game Start", 120, 100)
Player.getPlayerInfo();
if(allPlayers !== undefined){
var display_position = 130;
for(var plr in allPlayers){
if (plr === "player" + player.index)
fill("red")
else
fill("black");
display_position+=20;
textSize(15);
text(allPlayers[plr].Name + ": " + allPlayers[plr].distance, 120,display_position)
}
}
if(keyIsDown(UP_ARROW) && player.index !== null){
player.distance +=50
player.update();
}
}
}