This page describes some of the processes used to create the console-single player Unit Circle Game that is designed for a Window's based computer. When playing the game with a group, is helpful if each player has some reference circle to look at while one person reads the questions to the group.

Algorithm/Design

Steps with a * in front of them are not complete as of writing this algorthim and they may or may not be complete by presentation time in class.

  1. Declare constants.
  2. Declare functions.
  3. Inside Main()
    1. Declare and initialize local variables.
    2. Ask user for their name and setup files where the filename includes the username.
    3. Try opening one of the files named after the user and if it doesn't exist yet, create it.
    4. Greet the user with a message that is either for a first time user or a returning user.
    5. Give an additional information message.
    6. Call a function that draws the unit circle with labels.
    7. Reset console attributes back to normal.
    8. Call the levels of the game, one level at a time.
    9. Report the score and end the program.
  4. Inside Level 1()
    1. Initialize local variables including an array to hold the random numbers used in the game.
    2. Begin a loop that repeats for the number of rounds of the game.
      1. Create a random number for each round of the game.
      2. Check the random number to make sure it hasn't been used before. If it has repeat the above step until a new random number is found.
      3. Create a question about where the terminal side of the angle lands on the unit circle based on the random number chosen. The range of values will toggle between (-4π, 4π) or (-720°, 720°).
      4. When working in radians, call a reduceFraction function that prepares the number for display. Pass a π symbol constant to include π in the display when needed.
      5. Give the student 4 chances to answer each question and reduce the possible number of points by 1 after each wrong attempt.
      6. *Make sure the student gives a character answer in the range of 'A' through 'X' upper or lower case is fine.
      7. After the student gets a question right or runs out of attempts, report their current score and if they ran out of attempts, give the correct answer.
      8. *Record the round's results to the student's results file.
    3. Return the updated score back to main.
  5. *Inside Level 2()
    1. Initialize the variables
    2. Begin a loop that repeats for the number of rounds of the game.
      1. Create a random number for each round of the game.
      2. Call the draw unit circle function with the random parameter that highlights one of the points on the circle.
      3. Check the random number to make sure it hasn't been used before. If it has repeat the above step until a new random number is found.
      4. Ask the student for any standard angle associated with that point on the circle. Toggle between requesting answers in radians and answers in degrees.
      5. Give the student 4 chances to answer each question.
        1. Call a function that checks to see if the angle given has the same terminal side as indicated in the picture.
        2. Reduce the possible number of points by 1 after each wrong attempt.
        3. After all attempts or a correct answer update and report the score.
        4. If all attempts are incorrect, report the correct answer.
        5. Record the round results to the student's results file.
      6. Return the updated score back to main.
    3. *Level 3(): Level 3 play will be similar to level 1 play. The object will focus on identifying which points go with a given set of coordinates.
    4. *Level 4(): Level 4 play will be similar to level 2 play. The object will focus on identifying which coordinates will go with a given point.
    5. Inside the Draw Unit Circle function:
      1. This function uses structures that define blocks of color to be drawn to the screen.
      2. The function uses a row class where each row is made up of 2 vectors.
        • One vector keeps track of the color structures (color blocks).
        • A correspoding vector tells the number of each color blocks.
      3. The function uses row arrays where each array is made up of Row Objects from the Row Class.
      4. There is an if highlighted point statement with a switch statement inside of it to change some of the color block code for rows that are affected by the highlighted point.
      5. The function then calls a drawArrayOfRows function repeatedly for each array to draw the array to the screen.
    6. Inside the Reduce Fraction function: This function calls the Greatest Common Factor function and uses the gcf to reduce the numerator and the denominator. After it does that, it has several if else statments to format the fraction for display along with the symbol π and it returns a fraction string to the calling function.
    7. Inside the Draw Array of Rows Function: This is a simple function that calls the drawRow function for each array of the array class. The drawRow function is inside the class definition so a dot operator is needed for each RowDrawing object. Before each array, the drawArrayOfRows function draws the left hand margin. After each array, it draws the right hand margin. The drawArrayOfRows function inside the class handles the margins inbetween each row of the array.
    8. Other functions are called to handle repeative tasks. Their name indicates the task.
      • string BreakTextIntoLines(string text, int lineWidth),
      • void reverseArrayOrder(RowDrawing arry[], int arrySize),
      • void copyArray(RowDrawing origArray[], RowDrawing newArray[], int arrySize),
      • int greatestCommonFactor(int firstNum, int secondNum), and
      • bool repeatProblem(vector numVector, int number)

Colors

snipped of color experiment program

I created a separate program just to experiment with colors. If you wish to play around with the color program you may download and run the text file.

Pixel Drawings

Before creating the unit circle in the program, I used https://www.pixilart.com/ to design my project. In the project, I had to make each pixel from the drawing 2 characters wide so it looked like a square. I also had to put a character in each square to maintain the integrity of the drawing when the console is resized.

Pixels To Code

Shows the color block structure code. Shows the design code for the Row Drawing Constructor. Shows code for instaniating row drawing objects.

Trouble Shooting

Click on the image to see a larger version.

Shows code added for trouble shooting. Shows code of angle display mistakes. Shows code used to find investigate angle display mistakes.

Future Improvements

  • Finish the program.
  • Update this page.
  • Get control of the console size from the start and reset it at the end.
  • Have the program respond to a player's skill level and move on to the next level quickly when the player is doing well, but stay at the current level until the player master's that level.
  • Create a GUI version and add more levels that involve other points besides the key values. The other levels should focus on symmetries of the circle and also trig function values.
  • Observe users running the program to generate more ideas for improvements.
  • Create a mobile app version.

Let's Play

Hopefully, we will have some time left to actually run the program.

Contact Information:

e-mail:

shearsl@lcc.edu

Valid HTML 4.01 Strict
Valid CSS!

Last updated: March 27, 2019