Well im really really new to green foot and I want to make a Quiz type game But I have absolutely no clue how I gave it a try but that not getting me any where so can You guys help me Im not trying to make anything anything to complicated just a simple quiz question game that has
right and wrong answers and can Go from question to question after you answer . This is what i had so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.ArrayList; /** * Write a description of class MyWorld here. * * @author (your name) * @version (a version number or a date) */ public class MyWorld extends World { ArrayList questions = new ArrayList<Question>(); int currentQuestion = 0 ; int score = 0 ; /** * Constructor for objects of class MyWorld. * */ public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 400 , 1 ); //Define Questions String[] awnsers = { "15%" , "20%" , "30%" , "40%" }; questions.add( new Question( "How many percent of the worlds population live in Asia?" , awnsers, 3 )); showQuestion(currentQuestion); showScore(); checkClick(); } public void checkClick(){ MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse== null ) return ; int x = mouse.getX(); int y = mouse.getY(); } public void showScore(){ this .showText( "Score: " +score, 50 , 375 ); } public void showQuestion( int index){ Question q = (Question) questions.get(index); this .showText(q.question, 300 , 50 ); this .showText(q.awnsers[ 0 ], 300 , 100 ); this .showText(q.awnsers[ 1 ], 300 , 150 ); this .showText(q.awnsers[ 2 ], 300 , 200 ); this .showText(q.awnsers[ 3 ], 300 , 250 ); } } |