Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Processing 3.4 Q1: Dice-Game Simulator - Implement a dice-game simulator that uses the rules below. You will visualize the game as it progresses as

Using Processing 3.4

Q1: Dice-Game Simulator -

Implement a dice-game simulator that uses the rules below. You will visualize the game as it progresses as shown on the right: It will show your dice rolls as they happen, and keep track of your bank balance on the left. Each round of the game you roll one die to get a random number from 1 to 6. But this is a fancy spherical die. Show it by drawing a new circular image like the ones shown in the example. For each die roll, draw a white circle, with from 1 to 6 dots (called pips) equally spaced in a ring within the circle. Do not erase the old rolls, so that you see all of your rolls, as shown. You can see rolls from 1 to 6 in the sample image. Each die should be drawn in a random location, but be sure that the whole circle fits inside the window (and does not overlap the money bar on the left). The game rules are as follows. Depending on what you roll, your money gets a multiplier. If you roll a: 1 multiply your money by 1.5 2 = multiply your money by 1.3 3 = there is no change to your money 4 multiply your money by 0.2 (lose 80%!) 5 multiply your money by 0.8 (lose 20%!) 6 double your money There are two additional rules: if you get two 4s in a row, the second 4 will give you 5 times your money. (This will also happen for a 3rd, 4th, ... one, if you get really lucky.) But if you get two 6s in a row, the second six bankrupts you to $0. You will start the game with a certain amount of money ($40) and you must announce (that is, print to the console) a goal that you hope to reach (try $400). You must keep playing until either: 1) you reach or exceed your goal, or 2) you have less than $1 left. Show the amount of money as a vertical bar against a white background on the left side of the screen. A small bar near the bottom, as shown, means you havent got much money yet. A bar that reaches the top of the window means youve reached or exceeded your goal. If the bar disappears, youre broke. You should also draw a horizontal line to show the most money youve ever had during this game. In the example, the player has about $39.94 of the goal of $400, but at some point, had a bit more (about $52), as shown by the small line. You should also show the current money left in the bank after each roll as a text at the top of the left bar (money bar). Notes: You should make global constants for the parameters of the game, such as the colors used, what happens on the possible die rolls, etc. You should be able to quickly and easily change the appearance of the dice, the starting money or the goal, etc. You will also need global variables to keep track of your money, the maximum money you ever had, your previous roll, etc. Use a boolean variable to indicate whether or not the game is over. If the game is over, you shouldnt roll any more dice or change any money. Each frame you should play one round of the game. In order to slow it down so that you can watch the game, use the command frameRate(1); which will give only one frame per second. You can use (int)random(N)+1 to get a random integer value between 1 and N. Use println to print out the amount of money the player has, after each round, to the console, so that you can see whats going on. This will help a lot in testing your program. You can use the text(currentMoney, x, y) command to add the current amount of money in the bank after each roll. You should not erase the dice each frame, but you should erase and redraw the money bar each frame.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago