C++代写:CSCI1113 Merchant Ship

Introduction

代写一个商船的游戏,图像库基于X11来实现。完成商船的移动,云朵的移动和遮盖即可。

Instructions

This is an individual homework assignment. There are two problems worth 20 points each. Solve each problem below by yourself (unlike the labs, where you can work collaboratively), and submit each solution as a separate C++ source code file. Here are a few more important details:

  • You submit the correct file(s) through Moodle by the due deadline.
  • You should follow the example input and output formats given in each problem description. (match the input and output format exactly)
  • Regardless of how or where you develop your solutions, your programs compile and execute on cselabs computers running the Linux operating system.

Both parts of this homework involve the merchantShip.cpp on the class website (along with supporting files). This uses the GraphX files which require X11 and may not be installed on your computer. For this reason you might need to use a lab machine or remote connect (clicking to move on the map can be fickle, but playable). To compile and run the program, type:

g++ GraphX.o -lX11 merchantShip.cpp
./a.out

You are a merchant on the Indian ocean about 700 years ago. When you first run the program, some instructions on how to play the game will appear in the terminal. After this point you should always type in the map window (never enter anything in the terminal). The terminal will only be used to tell you text information (such as prices in cities). Set forth and make a profit!
Commands on the map:

Left click - Move to the current location. Moving near a city will enter it. Moving on land will end the game.

Commands in cities (type in the map window, not the terminal):

lower case letter - sell the trade good indicated by the parenthesis.
upper case letter - buy the trade good indicated by the parenthesis. 'q' or space - leave the city

For both parts, it is easiest to add your new code right above main(). If you add it elsewhere, you run the risk of having things not declared yet.

Problem A: Clouds (20 points)

Add some fluffy white clouds to the game. These should start at one of the random edges and go to another edge of the window (see pictures).

Hint: This is much easier if you use inheritance and borrow from other bits of the code.

Example: this cloud started in the top right and went to the bottom center.
When you are done, name the source code file [username]_10A.cpp. Here you replace [username] with your U of M email address. Then submit your program using the HW10A submission link in Moodle.

Problem B: Storm clouds (20 points)

Modify part A to have clouds be black storm clouds 20% of the time. If your ship is under a black storm cloud, you lose the game (i.e. stop the program wth an appropriate message).
For example: in this picture I am about to lose the game, as the cloud is moving onto my ship.
When you are done, name the source code file [username]_10B.cpp. Here you replace [username] with your U of M email address. Then submit your program using the HW10B submission link in Moodle.

Problem C: Upgrade your ship (10 points extra credit)

Add functionality to towns to be able to spend money to upgrade your storage in cities. It should cost 5000 currency to gain 5 units of storage. Do not not allow smaller purchase amounts, for example 1000 currency for 1 unit of storage. You should ensure that any cargo you currently have is carried over after increasing the capacity (and that no new cargo is added).
When you are done, name the source code file [username]_10C.cpp. Here you replace [username] with your U of M email address. Then submit your program using the HW10C submission link in Moodle.