Figure 1 depicts a screen shot from a game called Dodge. Dodge consists of: A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Figure 1 depicts a screen shot from a game called "Dodge". Dodge consists of: • A single player who can only move left and right and is controlled via the keyboard. Raindrops which appear in random positions in the top quarter of the screen and fall vertically downwards. The number of raindrops on the screen at any one time remains constant whenever a raindrop disappears off the bottom of the screen, a new one appears at the top of the screen. The objective of the game is to move the player so that he or she does not get wet, that is, the player must dodge the raindrops. If a raindrop touches the player then the game is over. Raindrops fall vertically Player moves horizontally left and right Figure 1: Dodge screenshot Provide the complete source code for the Dodge game. Your solution must be object-oriented. Certain classes have already been implemented and you should use these, where appropriate, in your solution. The interfaces for these classes are given in Listings 17 and 18 in Appendix 2. You may use very simple graphics for the game elements and you can assume that the player will not move beyond the borders of the screen. You are not required to separate the display logic from the game logic. Appendix 2: Existing Dodge Game Classes // This structure is used in the Screen class interface (see drawRectangle) struct Rectangle ( }; class Screen ( unsigned int x.pos; // top-left x-coordinate // top-left y-coordinate unsigned int y_pos; unsigned int width; // rectangle width unsigned int height; // rectangle height public: }; // Screen constructor // A "ScreenInitialisationError exception is thrown // if the Screen cannot be initialised // For the default screen, the top-left co-ordinate is (0,0) and // the bottom-right co-ordinate is (640,480) Screen(int width 640, int height=480); // Screen destructor, frees up all of Screen's resources -Screen(); }; // Returns the Screen width int width() const; // Returns the Screen height int height() const; // Updates the Screen with all the changes that have occurred since // the previous display call void display(); // Clears the Screen, by drawing over it in black void clear(); // Sets the foreground colour (the background colour is black) // R represents the red component (0 = minimum, 255= maximum) // G represent the green component (8 minimum, 255= maximum) // B represents the blue component (8 void setDrawingColour (int R, int G, int B); minimum, 255= maximum) // Draws a rectangle on the screen in the foreground colour void drawRectangle (Rectangle rect); // Draws a circle on the screen in the foreground colour void drawCircle(unsigned int centre.x, unsigned int centre_y, unsigned int radius); // The KeyBoardInputHandler class recognises the following keys enum Key (None, Space, Escape, LeftArrow, RightArrow, UpArrow, DownArrow); class KeyBoardInputHandler { Listing 17: Screen class public: // Returns the most recent key that was pressed // Only the keys specified in the enumeration type above are recognised // If no key has been pressed "None" is returned Key getKeyPressed() const; Listing 18: KeyboardInputHandler class. Figure 1 depicts a screen shot from a game called "Dodge". Dodge consists of: • A single player who can only move left and right and is controlled via the keyboard. Raindrops which appear in random positions in the top quarter of the screen and fall vertically downwards. The number of raindrops on the screen at any one time remains constant whenever a raindrop disappears off the bottom of the screen, a new one appears at the top of the screen. The objective of the game is to move the player so that he or she does not get wet, that is, the player must dodge the raindrops. If a raindrop touches the player then the game is over. Raindrops fall vertically Player moves horizontally left and right Figure 1: Dodge screenshot Provide the complete source code for the Dodge game. Your solution must be object-oriented. Certain classes have already been implemented and you should use these, where appropriate, in your solution. The interfaces for these classes are given in Listings 17 and 18 in Appendix 2. You may use very simple graphics for the game elements and you can assume that the player will not move beyond the borders of the screen. You are not required to separate the display logic from the game logic. Appendix 2: Existing Dodge Game Classes // This structure is used in the Screen class interface (see drawRectangle) struct Rectangle ( }; class Screen ( unsigned int x.pos; // top-left x-coordinate // top-left y-coordinate unsigned int y_pos; unsigned int width; // rectangle width unsigned int height; // rectangle height public: }; // Screen constructor // A "ScreenInitialisationError exception is thrown // if the Screen cannot be initialised // For the default screen, the top-left co-ordinate is (0,0) and // the bottom-right co-ordinate is (640,480) Screen(int width 640, int height=480); // Screen destructor, frees up all of Screen's resources -Screen(); }; // Returns the Screen width int width() const; // Returns the Screen height int height() const; // Updates the Screen with all the changes that have occurred since // the previous display call void display(); // Clears the Screen, by drawing over it in black void clear(); // Sets the foreground colour (the background colour is black) // R represents the red component (0 = minimum, 255= maximum) // G represent the green component (8 minimum, 255= maximum) // B represents the blue component (8 void setDrawingColour (int R, int G, int B); minimum, 255= maximum) // Draws a rectangle on the screen in the foreground colour void drawRectangle (Rectangle rect); // Draws a circle on the screen in the foreground colour void drawCircle(unsigned int centre.x, unsigned int centre_y, unsigned int radius); // The KeyBoardInputHandler class recognises the following keys enum Key (None, Space, Escape, LeftArrow, RightArrow, UpArrow, DownArrow); class KeyBoardInputHandler { Listing 17: Screen class public: // Returns the most recent key that was pressed // Only the keys specified in the enumeration type above are recognised // If no key has been pressed "None" is returned Key getKeyPressed() const; Listing 18: KeyboardInputHandler class.
Expert Answer:
Related Book For
Physics
ISBN: 978-0077339685
2nd edition
Authors: Alan Giambattista, Betty Richardson, Robert Richardson
Posted Date:
Students also viewed these accounting questions
-
One in five teachers stated that he or she became a teacher because of the long summer vacations. Find the mean and standard deviation for the distribution of teachers who say they became teachers...
-
How can a manager demonstrate that he or she is a responsible end user of information systems? Give several examples.
-
Was the decision maker aware that he or she was acting unfairly?
-
Read the Comp & Ben Case Study and answer the following question: To the degree job growth (and increased car sales that come from m costs) is based on two tier-wage structures, how sustainable...
-
Why do national income accountants compare the market value of the total outputs in various years rather than actual physical volumes of production? What problem is posed by any comparison over time...
-
In a protected environment, the population P of a certain endangered species recovers over time t (in years) according to the model P(t) = 30 1.149 x (a) What is the size of the initial population...
-
A parallel-plate capacitor with air between the plates and plate separation distance \(d\) is connected to a battery that maintains a potential difference \(V_{\text {batt }}\) between the plates....
-
Lena Holden began a professional practice on June 1 and plans to prepare financial statements at the end of each month. During June, Holden (the owner) completed these transactions: a. Owner invested...
-
A ( n ) _ _ _ _ _ _ _ _ _ _ contains information about a given person, product, or event. Attribute Column Field Record
-
Gabi Gram started The Gram Co., a new business that began operations on May 1. The Gram Co. completed the following transactions during its first month of operations. May 1 G. Gram invested $40,000...
-
Tom and Mara started working together two years ago to provide computer consulting services in their small town. They never discussed the nature of their business (although Tom once stated he had no...
-
Identify the correct action of the islamic bank in the following case study: Mr. Bilal made a binding promise to an Islamic bank that he would buy a van from the latter through a murabaha...
-
Which of the following is NOT a condition of the subject matter of the Islamic contract of sale? a. The subject matter must exist at the time of contracting except for salam and istisna contracts. b....
-
What is the research process for collecting, processing, and analyzing residual social media data used in social listening and monitoring?
-
Which of the following makes mudaraba different from a musharaka contract? I. Capital contribution II. Loss sharing III. Profits shared in pre-agreed ratio IV. Management participation a. I, II, and...
-
Explain the prohibited elements in Islamic contracts.
-
It is almost the end of a busy workweek. You feel you have been confronted by every challenge imaginable. You just received a panicked call from your immediate supervisor, Julianne Kwong, who is...
-
SCHEDULE OF COST OF GOODS MANUFACTURED The following information is supplied for Sanchez Welding and Manufacturing Company. Prepare a schedule of cost of goods manufactured for the year ended...
-
Show that the interference fringes in a double-slit experiment are equally spaced on a distant screen near the center of the interference pattern.
-
A spring fixed at one end is compressed from its relaxed position by a distance of 0.20 m. See the graph of the applied external force, Fx, versus the position, x, of the spring. (a) Find the work...
-
At what altitude above the Earth's surface would your weight be half of what it is at the Earth's surface?
-
Diehl Cleaners has the following statement of financial position items. Instructions Classify each item as an asset, liability, or equity. Analyze the effect of transactions. Accounts payable Cash...
-
Erin Danielle, the bookkeeper for Liverpool Ltd., has been trying to determine the correct statement of financial position for the company. The companys statement of financial position is shown...
-
Which of the following is true? a. Financial frauds have not occurred in U.S. companies because GAAP has detailed accounting and disclosure requirements. b. Transaction analysis is basically the same...
Study smarter with the SolutionInn App