Skip to content

Commit 5191db1

Browse files
committed
changed bullet speed and fixed query bug
1 parent 4da91b6 commit 5191db1

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

config_firestore.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
app_path = os.path.dirname(__file__)
1515

1616
# Define the path to the credentials file
17-
cred_path = os.path.join(app_path, 'keys/cs-fair-panic-firebase-adminsdk-ua0sv-2afc4b9471.json')
17+
cred_path = os.path.join(app_path, 'keys/cs-3050-final-project-538f66db8997.json')
1818

1919
# Initialize Firebase using the credentials file
2020
cred = credentials.Certificate(cred_path)
@@ -24,14 +24,12 @@
2424
db = firestore.client()
2525

2626
# Initializing database if empty
27-
2827
db_empty = False
2928

3029
scores_collection = db.collection('scores')
31-
3230
scores_docs = list(scores_collection.stream())
3331

34-
if len(scores_docs < 5):
32+
if len(scores_docs) < 5:
3533
for _ in range(5):
3634
doc_ref = db.collection('scores').document('Player' + str(time.time()))
3735
doc_ref.set({'username': 'JDH', 'stage': 2, 'score': 50})

windows.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def resource_path(relative_path):
3838

3939
class StartView(arcade.View):
4040
""" View that is initially loaded """
41+
def __init__(self):
42+
super().__init__()
43+
self.queried = False
44+
self.top_five = None
4145

4246
def on_show_view(self):
4347
""" This is run once when we switch to this view """
@@ -62,6 +66,11 @@ def on_show_view(self):
6266

6367
def on_draw(self):
6468
""" Draw this view """
69+
70+
if not self.queried:
71+
self.top_five = query_database()
72+
self.queried = True
73+
6574
self.clear()
6675
# Draw stars
6776
for star in self.star_list:
@@ -255,6 +264,7 @@ class LeaderboardView(arcade.View):
255264
def __init__(self, game_view):
256265
super().__init__()
257266
# Create UI manager and star list
267+
self.queried = False
258268
self.top_five = None
259269
self.star_list = []
260270
self.ui_manager_leaderboard = arcade.gui.UIManager()
@@ -286,11 +296,11 @@ def on_show_view(self):
286296

287297
def on_draw(self):
288298
self.clear()
289-
# information from the firebase database
290-
queried = False
291299

292-
if not queried:
300+
# Querying once
301+
if not self.queried:
293302
self.top_five = query_database()
303+
self.queried = True
294304

295305
for star in self.star_list:
296306
x, y = star
@@ -406,6 +416,7 @@ def quit_button_click(self, event):
406416
# The user restart when restart button is clicked
407417
def restart_button_click(self, event):
408418
""" If the user presses the mouse button, re-start the game. """
419+
self.queried = False
409420
self.ui_manager_leaderboard.disable()
410421
game_view = GameView()
411422
game_view.setup()

0 commit comments

Comments
 (0)