#include <acknex.h>
#include <default.c>
typedef struct RND_Q {
BMAP* bmap;
char* model;
int answer;
} RND_Q;
RND_Q* rnd_q; //pointer for array of structs
int int_rndQuestionCount; //stores the number of random questions
int int_rndQuestionSelected;
//panel for displaying the question
PANEL* pnl_question = {
flags = SHOW;
}
//function for adding question to the pool
void question_add(char* bmp, char* model, int answer){
int i = int_rndQuestionCount;
int_rndQuestionCount++;
rnd_q = realloc(rnd_q, sizeof(RND_Q) * (int_rndQuestionCount));
rnd_q[i].bmap = bmap_create(bmp);
rnd_q[i].model = model;
rnd_q[i].answer = answer;
}
void main(){
wait(1);
question_add("q01.bmp", "q01.mdl", 1);
question_add("q02.bmp", "q02.mdl", 4);
question_add("q03.bmp", "q03.mdl", 2);
question_add("q04.bmp", "q04.mdl", 1);
random_seed(0);
int_rndQuestionSelected = random(integer(int_rndQuestionCount)); //randomly generates a question
//rnd_q[int_rndQuestionSelected].bmap; //stores the question image
//rnd_q[int_rndQuestionSelected].model; //stores the mode name
//rnd_q[int_rndQuestionSelected].answer; //stores the correct answer
//so to display the question in pnl_question use
pnl_question.bmap = rnd_q[int_rndQuestionSelected].bmap;
}