text based gamemaker

Information about object: obj_question
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

//set variables:
data=0;
q=1;
//open file and read questions:
file=file_text_open_read("questions.txt");

while (!file_text_eof(file))//loops until end of file
{
data++;
question[data,1]=file_text_read_string(file);//read question
file_text_readln(file);
question[data,2]=file_text_read_string(file);//read answer 1
file_text_readln(file);
question[data,3]=file_text_read_string(file);//read answer 2
file_text_readln(file);
question[data,4]=file_text_read_string(file);//read answer 3
file_text_readln(file);
question[data,5]=file_text_read_real(file);//read correct answer 1
file_text_readln(file);

}

file_text_close(file);
Step Event:
execute code:

if (keyboard_check_pressed(vk_left))  {q-=1;}//change question number
if (keyboard_check_pressed(vk_right))  {q+=1;}//change question number
if q==0 q=data;//keep in range
if q==(data+1) q=1;//keep in range

Draw Event:
execute code:

//draw the data
draw_text(50,100,question[q,1]);
draw_text(50,200,question[q,2]);
draw_text(50,300,question[q,3]);
draw_text(50,400,question[q,4]);
draw_text(50,500,question[q,5]);

No comments:

When Bad People Make Good Art

I offer six guidelines on cancel culture ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏...

Contact Form

Name

Email *

Message *