# Goldcenter ygoldgetcenter goldcenterxcoord

• Homework Help
• 4
• 100% (3) 3 out of 3 people found this document helpful

This preview shows page 3 - 4 out of 4 pages.

goldcenter = Y[gold].getCenter() goldcenter_xcoord = goldcenter.getX() goldcenter_ycoord = goldcenter.getY() if abs(A - selectionA) <= 15 and abs(B - selectionB) <= 15: Y[j].setFill(colorlist[j]) if abs(selectionA - goldcenter_xcoord) <= 15 and abs(selectionB - goldcenter_ycoord) <= 15: Y[gold].setFill("gold") # make a loop so that you can keep clicking for the gold circle and then close the other circles for l in range(2000): for m in range(len(Y)): if m != gold: Y[m].move(0, 2000) # make a count of the number of clicks done prior to finding the gold circle CLICKS += 1 clickscount.setText("Clicks: " + str(CLICKS)) # index clicks to third position of index [_, _, count] # display a text once the round has ended, aka, gold was found if ROUND != 5: # once gold has been clicked on, display a message in the window # use get mouse where when the player clicks a new game is started ROUND +=1 roundcount.setText("Round: " +str(ROUND)) # once ROUND = 5, put message inside game window after all the circles leave # message1 = Text(Point(240, 260), "You found the gold!") # message1.setTextColor("black") # message1.setSize(24) # message1.setStyle("bold") # message1.draw(game) # message2 = Text(Point(240, 260), "Click anywhere to begin a new game.") # message2.setTextColor("black") # message2.setSize(18) # message2.draw(game) # index the number of rounds completed into the first position of the index [round, _, _] # combine the three indexes using lists (round, playername, count} and save to avariable called Index # return objects along with "Index" return game,ROUND,CLICKS # Create a function that will close both the windows when the user clicks EXIT def start_game(game, win): # Creat a while loop repeat the start_game function until a mouse click is in EXIT click = win.getMouse() x, y = click.getX(), click.getY() if x > 185 and x < 245 and y > 120 and y< 193: game.close() win.close() # create lists and circle objects function def circle_grid(game): # Create a list that creates 15x15 grid of black filled circles Center = Point(30,70)
# stors the black circles as elements in a list Y = [] for x in range (15): for y in range (15): circ = Circle(Center, 15) circ.setFill("black") Center = Point ((Center.getX()+30), (Center.getY()))