Q3: State variables, conditional statements and random numbers: Random button generator with counter. Create a Processing...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/05/66448a9bc3438_96366448a9bad315.jpg)
Transcribed Image Text:
Q3: State variables, conditional statements and random numbers: Random button generator with counter. Create a Processing program that creates a random button of a fixed size and colour (use a different color scheme than the one shown in Figure 3). The program should interact with the user as follows: . Choose two different colours: COLOR1 and COLOR2. When the button is first displayed, it should use COLOR1, should contain the number "5", and should be in a random position in the canvas. The entire button should fit in the canvas. If the mouse button is pressed when the mouse is within the button, the color of the button should change to COLOR2. It should remain that colour for as long as the mouse button is held. Once the mouse button is released, the color should change back to COLORI, the number should be reduced to 4, and the button should move to another random location. This process should repeat until the counter is reduced to 0 at which point "STOP" should be displayed on the button. The button should no longer move or respond to mouse clicks. Create the following functions clickedOnButton() should check to see if the mouse button is pressed when the mouse pointer is in the button. If it is, it should change the color of the box. clicked OffButton() - should check to see if the mouse button has 1 4 Figure 3: Random Block Generator been released after it was pressed earlier. Use a separate flag (or global variable) to keep track of whether or not the mouse was pressed in the button. printCounter() should draw the counter number in the button. You will be required to declare and use: A final float variable for the button size o Float variables for the button location (X and Y coordinates) o A boolean variable to keep track of whether or not the button has been pressed A counter to keep track of the number to be displayed in the button You may create and use additional variables or constants as needed. Q3: State variables, conditional statements and random numbers: Random button generator with counter. Create a Processing program that creates a random button of a fixed size and colour (use a different color scheme than the one shown in Figure 3). The program should interact with the user as follows: . Choose two different colours: COLOR1 and COLOR2. When the button is first displayed, it should use COLOR1, should contain the number "5", and should be in a random position in the canvas. The entire button should fit in the canvas. If the mouse button is pressed when the mouse is within the button, the color of the button should change to COLOR2. It should remain that colour for as long as the mouse button is held. Once the mouse button is released, the color should change back to COLORI, the number should be reduced to 4, and the button should move to another random location. This process should repeat until the counter is reduced to 0 at which point "STOP" should be displayed on the button. The button should no longer move or respond to mouse clicks. Create the following functions clickedOnButton() should check to see if the mouse button is pressed when the mouse pointer is in the button. If it is, it should change the color of the box. clicked OffButton() - should check to see if the mouse button has 1 4 Figure 3: Random Block Generator been released after it was pressed earlier. Use a separate flag (or global variable) to keep track of whether or not the mouse was pressed in the button. printCounter() should draw the counter number in the button. You will be required to declare and use: A final float variable for the button size o Float variables for the button location (X and Y coordinates) o A boolean variable to keep track of whether or not the button has been pressed A counter to keep track of the number to be displayed in the button You may create and use additional variables or constants as needed.
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
H is awarded an all-expense paid vacation to Hawaii worth $5,000 in recognition for his outstanding service in educating members of the profession, from the professional organization known as the...
-
A regular language is a language that can be defined by a regular expression. 0 2 . 1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
a. Find the nth-order Taylor polynomials for the given function centered at the given point a, for n = 0, 1, and 2.b. Graph the Taylor polynomials and the function. f(x)=x, a = 9
-
The National Institute on Drug Abuse issued the report Monitoring the Future, which addressed the issue of drinking, cigarette, and smokeless tobacco use for eighth, tenth, and twelfth graders....
-
Waves on a Stick a flexible stick 2.0 m long is not fixed in any way and is free to vibrate. Make clear drawings of this stick vibrating in its first three harmonics, and then use your drawings to...
-
The Brown Company produces two products: \(\mathrm{X}\) and \(\mathrm{Y}\). The unit contribution margins are \(\$ 8\) and \(\$ 5\) for \(X\) and \(Y\), respectively. Production information is given...
-
The financial statements of The Hershey Company appear in Appendix B, following the financial statements for Tootsie Roll in Appendix A. Instructions (a) Based on the information contained in these...
-
1. Mr Vomit-Bucket is interested in which type of alcohol affects balance the most. He therefore gives four groups of unique participants beer, vodka, whisky, or wine, and then he has them walk in a...
-
3 A company with an accounting date of 3 1 October carried out a physical check of inventory on 4 November 2 0 X 3 , leading to an inventory value at cost at this date of $ 4 8 3 , 7 0 0 . Between 1...
-
The Converting Department of Toren Company had 800 units in work in process at the beginning of the period, which were 75% complete. During the period, 16,800 units were completed and transferred to...
-
Prepare journal entries to record transactions a through h a. Raw materials purchased on credit, $102,000. b. Direct materials used, $42,500. Indirect materials used, $15,000. c. Direct labor used,...
-
Find the zeros of the function and state the multiplicities. f(x)=4x(9x+8)(2x+5)(x+ 6)(x-6)
-
Mason Metal Creations is a medium size company located in Barrie, Ontario. The company specializes in designing and producing metal elements and home decor. The Metal Elements division can transfer...
-
What do we precisely mean when we refer to embedded systems? Discuss the numerous uses of the embedded system.
-
A company that produces SSS handkerchiefs was fairly certain that their handkerchief brand had a 20% market share. In a market survey involving 3,000 handkerchief buyers, 660 expressed a preference...
-
Explain why it is not wise to accept a null hypothesis.
-
The City of Bernard starts the year of 2010 with the following unrestricted amounts in its General Fund: cash of \($20,000\) and investments of \($70,000\). In addition, it holds a building bought on...
-
Use the information in problem 40 to prepare the 2010 fund-based financial statements for the governmental funds and the proprietary funds. A statement of cash flows is not required. Assume that...
-
On the first day of Year 4, the city receives a painting as a gift that qualifies as a work of art. It has a 30-year life, is worth $15,000, and is being displayed at one of the local parks. The...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App