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

2017/3/26

How to Link 'Q&A' Class to Object (If Object Falls into River, Then run 'Q&A')

Dphi96 Dphi96

2017/3/26

#
I'm new to Greenfoot. I'm doing a college project and in this project our criteria is to create an educational game. The game i intend to make is very simple - The 'main_character' has to get from point A across to point B, via Jumping onto wood, without falling through the gaps, into the 'river'. In order to make it educational. I was trying to implement some sort of Question & Answer action. So, if the character falls into the river then 'Ask them a Question i.e. "12 x 12 =" and they would be given with four options to choose from. If they select correct answer then "Correct, You get Another Try" (Set Character back to original start point) else "Incorrect, you Lose!". - I went on YouTube and got the code to create a simple looking 'Q&A' Class, I put it in an array, so I can add multiple questions, easily. The Problem is, I don't know how to LINK it to the 'character'. So if Character > Falls into River > Run 'Q&A' class. (I need to know what I would have to do inorder to ensure the 'Q&A' class runs.
Super_Hippo Super_Hippo

2017/3/26

#
I obviously don't know what your Q&A class looks like, but it is likely that you have to create an instance of it when you want to run it (so when your main character fell into the river). It is possible that you also need to add it to the world.
danpost danpost

2017/3/26

#
In your case, you can probably have the Q&A run in a separate world and when the answer is right, start a new game world. So, it would be something like: if character falls into river, set a new question world active; and if answer is correct, set a new game world active; else show 'You Lose' message;
You need to login to post a reply.