Need Help Making A Game

For my school project, I’m creating a free running game (C-SHARP) that requires the user to answer math questions as they play. I created the base idea using a Brackeys video but want to further modify it. So far it looks like this :

However I want to add a feature that would use C# to create code that randomly generates a math equation on the UI. After the equation shows up there will be boxes in front that will show up and will all have 3D text on top of them with different answers. The player must go through the box with the right number on it too pass. If the player gets the right answer, they can pass through and go to the next equation. But if the player fails the game is restarted. Any help or guidance would be appreciated.

Here’s what you’d need.

  1. An array of strings representing the math equation
  2. (Assuming your game has a bank of preset equations to choose from) - a corresponding array of correct answers to the equation, stored at the corresponding index to their question
  3. An RNG so the equation can be posted randomly.

Once you have those, you’ll want to first generate the random number, something between zero and the size of your array minus one (remember array index starts at 0), then you store that number for later.

Next, When you arrive at the point in space that you want to ask the question, set your UI element’s text component to be your array of math equation strings at the index of the number you generated earlier, then, display the answer from the correct answers array by choosing the index of the same number as your equation.

Next, choose two more (or however many incorrect answers you want to show) random numbers between zero and your array length minus one. Do a quick check that neither of the random number’s generated match your first generated number, if they do, generate them again (you don’t want the correct answer displayed twice).

Next, Generate a number between 1 and x ( x being the number of possible answers you want displayed) - this will be where your correct answer is displayed. It doesn’t matter where the other answers are displayed because they are wrong/randomly chosen already. You should have an array of positions where to display the answers, so display the correct answer at the index of the most recently generated number. Continue to place the rest of the incorrect answers, filling in to the left of the first answer’s placement (if possible), then to the right(if possible).

The correct answer should be marked as such when it is first chosen out of the array, and so checking it should require a simple boolean check as soon as an element is clicked. Upon clicking, if the check returned true, run a continue function, otherwise, run a restart function.

This is conceptually how I would do it were I in your position. It is a very simple implementation with C#, and if you know the foundation, it shouldn’t be difficult. If you have no foundation in C# or Java, I would strongly recommend you obtain one before trying to tackle a logic based project like this.

You can always create an int variable (x) and assign it a random range between whatever numbers you prefer, then repeat the process for another int variable (y). Then create another int variable (z) that = x+y. That will be the right box they go through. You can subtract from or add to the right answer and make those the wrong answers.