CSCI 261 - Programming Concepts

Spring 2019 - A7 - Stargate

Quick Links: Canvas | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |

This assignment is due by Tuesday, April 16, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A, L7B, L7C .

· Instructions · Rubric · Submission ·


Instructions


Your task for this assignment is to extend Lab7B by writing out the modified star data and then drawing a star map similar to the one shown here:


Use your Lab7B as a starting point. You will need to read in the stars.txt file, process the data, write out the new data, and then plot it.


Data File


You will then need to write the file ModifiedStars.txt. Your ModifiedStars.txt file will need to consist of three fields per line, all tab separated:

  • The first two fields are the x and y coordinates for the star. The coordinates are in SFML's coordinate system, i.e., position (0, 0) is in the upper-left corner of the picture, and the maximum x and y values are the width and height of the picture (in pixels).
  • The third field is the brightness of the star, and all brightness fields should be between 0.0 and 8.0.

This information should match the result from Lab7B.


Drawing a Star


In your code, you'll need to draw a star. Since stars look like circles, use the CircleShape class. Each circle needs a non-zero radius; use the setRadius function to set this to 2. Then, use this star object to draw each star as you read its properties (i.e., coordinates and brightness) from the data file. For example, to set a star at position xPixel and yPixel use the following:

star.setPosition(Vector2f(xPixel, yPixel));

A star can be drawn on the window using the following function call:

window.draw(star);


Shades of Gray


One of the most common ways to represent colors is with the RGB color model. In this model, each color is represented with three numbers in the range 0 to 255 that represent the amount of red, green, and blue to include in the color. For example, (255,0,0) is the color red and (255,255,0) is the color yellow (i.e., red and green combined). Any color with the same amount of red, green, and blue is a shade of gray. We will use shades of gray to draw our stars with different brightness; thus, in this project, you should include the same amount of red, green, and blue in your colors drawn (but feel free to play with the other more colorful colors!)

SFML has a color function that allows the drawing of specific colors using the RGB model. For example, each of the following examples sets the fill color of a star to a different shade of gray:

// Black
star.setFillColor(Color(0, 0, 0));

// Dark gray
star.setFillColor(Color(64, 64, 64));

// Medium gray
star.setFillColor(Color(128, 128, 128));

// Light gray
star.setFillColor(Color(192, 192, 192));

// White
star.setFillColor(Color(255, 255, 255));

To determine the shade of gray for each star drawn in this project, you need to scale the brightness value of the star to an integer value between 0 and 255 and set the fill color using that value, as shown above. For example, if brightness is a double variable holding a star's brightness value in the range 0.0 to BRIGHTEST_STAR, to convert it to an integer value in the range 0 to 255, you would use the following:

int shadeOfGray = (int)( ( 255.0 * brightness ) / BRIGHTEST_STAR );

You would then use this shadeOfGray variable to set the drawing color and fill color:

star.setFillColor(Color(shadeOfGray, shadeOfGray, shadeOfGray));


Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement Description
2 All code submitted properly.
6 All labs completed and submitted
L7A, L7B, L7C
2 Output matches stars test file.
2 Written output file has proper format.
2 Written output file has correct data.
2 SFML window opens and draws properly.
4 Stars are colored properly in gray scale.
4 Stars are positioned properly.
2 Stars are sized correctly.
2 SFML window closes cleanly.
2 (1) Comments used
(2) Coding style followed
(3) Appropriate variable names, constants, and data types used
(4) Instructions followed
30 Total Points

This assignment is due by Tuesday, April 16, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A, L7B, L7C .


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available. The following instructions are copied from How to Submit Homework.


It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work. And that makes us very unhappy. And when we're unhappy, we give penalties. Thus, make us happy.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:
  1. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set7
    2. Inside Set7, create 4 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L7A, L7B, L7C, and A7).
    3. Copy your main.cpp , additional header & source files, plus the CMakeLists.txt file into the subdirectories of Set7 (steps 1-2), zip this Set7 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
    4. For example, when you zip/submit Set7, there will be 4 sub-folders called L7A, L7B, L7C, and A7 inside the Set7 folder, and each of these sub-folders will have a file called main.cpp, additional header & source files, plus the CMakeLists.txt file .

  2. Using Windows Explorer (not to be confused with Internet Explorer), find the file named "main.cpp" located inside the folder for the particular lab or homework assignment you will submit.

    STOP: Are you really sure you are viewing the correct assignment's folder?

  3. Now, for A7, right click on the main.cpp to copy the file. Then, return to the Set7/A7 folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code into the Set7/A7 folder. Repeat this for each additional header & source file you have with this assignment, plus CMakeLists.txt.

    Follow the same steps for L7A, to put a copy of your lab's main.cpp into the Set7/L7A folder. Repeat this process for Set7/L7B, Set7/L7C.

    STOP: Are you sure your Set7 folder now has all your code to submit?

  4. Now, right-click on the "Set7" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set7 folder with sub-folders that each contain a main.cpp file in it?

  5. After the previous step, you should now see a "Set7.zip" file.

  6. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  7. Find Set7, click on it, find the "Submist Assignment" area, and then click the "Choose File" button.

  8. Find the "Set7.zip" file created earlier and click the "Open" button.

    STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?

  9. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  10. No, really, make sure you click the "Submit Assignment" button to actually submit your homework. Clicking the "Choose File" button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!

  11. Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set7" folder and only the "Set7" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this homework, and you must click the "Submit Assignment" button. Not doing these steps is like bringing your homework to class but forgetting to hand it in. No concessions will be made for incorrectly submitted work. If you incorrectly submit your homework, we will not be able to give you full credit. And that makes us unhappy.


This assignment is due by Tuesday, April 16, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A, L7B, L7C .

Last Updated: 04/03/19 16:10


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0