Goals Practice graphic programming Practice designing programs (e.g., list, loop, creating random variables) Practice creating random variables
Fantastic news! We've Found the answer you've been seeking!
Question:
Goals
- Practice graphic programming
- Practice designing programs (e.g., list, loop, creating random variables)
- Practice creating random variables
Description
Write code to implement graphic-based game. The video below shows how to play the game. First, as players click to start a game, 10 random numbers will be shown and randomly placed. The task is to click numbers in increasing order as fast as possible. If players click the proper number (i.e., smallest number shown), the number being clicked will disappear. Then, "Good" message will show and the remaining count will decrease. Otherwise, the message will say "Oops" (i.e., click the wrong number or random places). After all the numbers are finished, a "Clear" message will come along with how many seconds have been spent. See below for details.
Hint 1 (how to detect the click event from any objects) - you may want to get the mouse click event and its (x, y) location. Assume that you have a text object located in (x_obj ect, y_object). Then measure their Euclidean (i.e., Pythagorean) distance and if the distance is less than or equal to 5, you can safely assume that the user is clicking that object. import math = math.sqrt((x - x_object)**2 + (y - y_object)**2) if d < 5.0: else Hint 2 (Time measurement) - Use the "time" library. import time start = time.time() # put this code at the starting point time_elapsed = time.time() - start # put this code at the end Hint 3 (Random variables) - Please research yourself about the "random" library
Related Book For
Accounting Information Systems
ISBN: 9780132871938
11th Edition
Authors: George H. Bodnar, William S. Hopwood
Posted Date: