This site requires JavaScript, please enable it in your browser!
Greenfoot back
Joaquin
Joaquin wrote ...

2017/9/5

Maths Quiz Game

Joaquin Joaquin

2017/9/5

#
hello everyone I need help making a maths quiz game which is based for 22-25 and it has to be educational. I have no idea where to start so some help would be awesome thanks :)
Yehuda Yehuda

2017/9/6

#
You can start with: Interacting with Greenfoot
Joaquin Joaquin

2017/9/6

#
I just checked that and we have already done that in class. I need to learn how I can make questions and answer pop up so that the person playing the game can answer the questions. Thanks :)
Super_Hippo Super_Hippo

2017/9/6

#
As a really easy version:
int a = Greenfoot.getRandomNumber(10);
int b = Greenfoot.getRandomNumber(10);
int result = a + b;
int answer = Integer.parseInt(Greenfoot.ask("How much is " + a + " + " + b + "?"));
if (result == answer)
{
    //showing that the answer was correct
}
else
{
    //showing that the answer was not correct
}
You have different possibilities to do it. You can either have predefined questions and randomly choose one, if you do that, you also have predefined answers and the user have to choose one or like above, the question is random and the user has to type in the result. If you look at the code example, two numbers between 0 and 9 have to be added. This is not really a difficult thing. You might want to use higher numbers, more numbers (not only 2), not only +. If you don't want to use the ask method, you can also create an input box field in the world and answer the question which can be displayed in the world.
Joaquin Joaquin

2017/9/7

#
Thank you so much :D
Joaquin Joaquin

2017/9/11

#
Hey, guys, I'm back, I just needed to know if anyone knew how to make a timer so that after some time the player that is playing the game gets sent to the main menu and also if anyone knows how to make lives so that after some time the player loses one life then after like 20 seconds the person loses another life and gets sent to the menu. Thanks :)
danpost danpost

2017/9/11

#
Timers and Lives are basically values that are displayed and used to control the game. You could check out my tutorial. It should, in general, help. EDIT: minor adjustments might need to be made to the given code due to the version of Greenfoot you are using.
You need to login to post a reply.