# Pacman Math: Eat the right number

**2**

I want to help my son learn his math facts in a fun, engaging way. I want to make a game that let's my son's avatar "eat" one of several numbers that appear on the screen. One of the numbers is the right answer to a math problem that appears on the screen also. For example, the scene has a math problem like "3 x 3 = ?". Besides my son's avatar (an animated actor that is chomping) there are several numbers. He can use the keyboard to move the avatar and "eat" one of the numbers in the scene. One of the numbers is the correct number to solve the math problem. When the avatar collides with the right number, the score increments and the next scene appears (same scene but with a different math problem/right answer).

I have the "chomping" avatar and can move it around.

I think I understand how to use attributes to generate the random numbers I need for the math problem.

I don't understand how I associate the attribute with actors that represent numbers and then test for the collision.

I'd really appreciate any tips anyone can provide.

## Comments

11,936Set up a table with columns like this, where the first value is text and contains the problem, the second value is the correct answer, and the remaining values are incorrect answers:

3 x 3 9 4 7 8

2 x 4 8 3 5 9

Choose a problem by changing an attribute game.row to random(1,tableRowCount(tableName)) or just increment it to go in order.

Use Display Text to display the problem: tableCellValue(tableName, game.row, 1)

For the guess actors, ... well, I'll have to come back to that because I ran out of time getting my sons ready for school!

New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User

2,864Here is an example that generates random numbers. (The interface is ugly but the underlying methods are sound.)

2Thank you for the help! Wow! RThurman, that is really helpful. Thank you.

2,864You are welcome. Glad you can use it!