@@ -38,6 +38,10 @@ def resource_path(relative_path):
3838
3939class 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