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.
- Declare constants.
- Declare functions.
- Inside Main()
- Declare and initialize local variables.
- Ask user for their name and setup files where the filename includes the username.
- Try opening one of the files named after the user and if it doesn't exist yet, create it.
- Greet the user with a message that is either for a first time user or a returning user.
- Give an additional information message.
- Call a function that draws the unit circle with labels.
- Reset console attributes back to normal.
- Call the levels of the game, one level at a time.
- Report the score and end the program.
- Inside Level 1()
- Initialize local variables including an array to hold the random numbers used in the game.
- Begin a loop that repeats for the number of rounds of the game.
- Create a random number for each round of the game.
- 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.
- 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°).
- 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.
- Give the student 4 chances to answer each question and reduce the possible number of points by 1 after each wrong attempt.
- *Make sure the student gives a character answer in the range of 'A' through 'X' upper or lower case is fine.
- 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.
- *Record the round's results to the student's results file.
- Return the updated score back to main.
- *Inside Level 2()
- Initialize the variables
- Begin a loop that repeats for the number of rounds of the game.
- Create a random number for each round of the game.
- Call the draw unit circle function with the random parameter that highlights one of the points on the circle.
- 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.
- Ask the student for any standard angle associated with that point on the circle. Toggle between requesting answers in radians and answers in degrees.
- Give the student 4 chances to answer each question.
- Call a function that checks to see if the angle given has the same terminal side as indicated in the picture.
- Reduce the possible number of points by 1 after each wrong attempt.
- After all attempts or a correct answer update and report the score.
- If all attempts are incorrect, report the correct answer.
- Record the round results to the student's results file.
- Return the updated score back to main.
- *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.
- *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.
- Inside the Draw Unit Circle function:
- This function uses structures that define blocks of color to be drawn to the screen.
- 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.
- The function uses row arrays where each array is made up of Row Objects from the Row Class.
- 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.
- The function then calls a drawArrayOfRows function repeatedly for each array to draw the array to the screen.
- 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.
- 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.
- 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
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
Trouble Shooting
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.