Write a sketch in Processing that has the following: 1. an IFLabel with the question "Would you like $1,000,000?" 2. an IFButton with the answer "Yes", and 3. an IFButton with the answer "No" All...

Write a sketch in Processing that has the following: 1. an IFLabel with the question "Would you like $1,000,000?" 2. an IFButton with the answer "Yes", and 3. an IFButton with the answer "No" All three of these elements should be located near the middle of a 640 x 480 window with a gray background (128, 128, 128). When the user clicks on the "Yes" button, change the label text to several dollar signs, and when the user clicks on the "No" button close the program. However, this is much too easy for the user to get the million dollars, so we will make it harder! As the user moves their mouse towards the "Yes" button, the "Yes" button should try to escape. The logic for calculating where the "Yes" button moves to is as follows: 1. Calculate how many pixels the mouse is to the left or right of the button and save this as dx. dx should be negative to the left of the button, positive to the right of the button, and O above, below, or on the button. 2. Calculate how many pixels the mouse is above or below the button and save this as dy. dy should be negative above the button, positive below the button, and Obeside or on the button. 3. Calculate the Manhattan distance between the mouse and the button, mdist = abs(dx) + abs(dy). 4. If mdist = 0 or mdist > 50, don't move the button. 5. Calculate a new x coordinate, as newX = currentX - 150 dx/mdist/mdist. 6. Calculate a new y coordinate, as newY = current Y - 150 dy/mdist / mdist. 7. If part of the button would move off of the window, reset its position to where it started. Otherwise, move the button to (newX, newY). For testing purposes, you may wish to change the 150 in the formula to a 50, as the button is pretty difficult to catch! You should submit a PDE file to this assignment.
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here