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
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" libraryProject4 Click to start
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import tkinter as tk import random import time Task 1 Create window sized 500 x 500 pixels and title...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started