---********************
---**** variables *****
---********************

--***********define colours
red = Color.new(255, 0, 0)
green = Color.new(0, 255, 0)
blue = Color.new(0, 0, 255)
pink = Color.new(180, 0, 180)
white = Color.new(255, 255, 255)

screen.waitVblankStart(3)
screen.waitVblankStart(3)
screen.waitVblankStart(3)

--load settings
dofile("./settings.txt")
if quizdir == 1 then
quizdir = "quiz1"

elseif quizdir == 2 then
quizdir = "quiz2"

elseif quizdir == 3 then
quizdir = "quiz3"

elseif quizdir == 4 then
quizdir = "quiz4"

elseif quizdir == 5 then
quizdir = "quiz5"

elseif quizdir == 6 then
quizdir = "quiz6"

elseif quizdir == 7 then
quizdir = "quiz7"

elseif quizdir == 8 then
quizdir = "quiz8"

elseif quizdir == 9 then
quizdir = "quiz9"

elseif quizdir == 10 then
quizdir = "quiz10"

elseif quizdir == 11 then
quizdir = "quiz11"

elseif quizdir == 12 then
quizdir = "quiz12"

elseif quizdir == 13 then
quizdir = "quiz13"

elseif quizdir == 14 then
quizdir = "quiz14"

elseif quizdir == 15 then
quizdir = "quiz15"

end

--load questions
dofile("./" .. quizdir .. "/quiz.txt")

-----OTHER VARS
qnumber = 0 --before was 1 without the sound
score = 0
scorew = 0
cursor = 1 --CAN BE 1,2,3 or A,B,C
correct = nil
gamestate = 1 --can be 1 (playing) or 0 (ended)

--images
bground = Image.load("./" .. quizdir .. "/bg.jpg")

Cursor = { x = -200, y =-200,  img = Image.createEmpty(10, 10) }
Cursor.img:clear(red)

--FUNCTIONS

--move cursor
function movecursor()

if pad:down() and cursor < 3 then --down
cursor = cursor + 1
screen.waitVblankStart(5)
end

if pad:up() and cursor >1 then -- UP
cursor = cursor - 1
screen.waitVblankStart(5)
end

end

--answer (answer the question)

function answer()

if pad:cross() and cursor == correct and qnumber <25 then
score = score + 1
qnumber = qnumber + 1
screen.waitVblankStart(15)


elseif pad:cross() and cursor == correct and qnumber ==25 then
score = score + 1
gamestate = 0
screen.waitVblankStart(15)





elseif pad:cross() and cursor ~= correct and qnumber <25 then

scorew = scorew + 1
qnumber = qnumber + 1

screen.waitVblankStart(15)









elseif pad:cross() and cursor ~= correct and qnumber ==25 then
score = score - 0
gamestate = 0
screen.waitVblankStart(15)
end




end



---------------------------------GAME
while true do

--read pad input
pad = Controls.read()

-- clear screen
screen:clear()


--if game is playing
if gamestate == 1 then
--BLITS
	screen:blit(0,0,bground) --bground
		if cursor == 1 then --CURSOR (state A)
			screen:blit(48,140, Cursor.img)
		elseif cursor == 2 then --CURSOR (state B)
			screen:blit(48,150, Cursor.img)
		elseif cursor == 3 then --CURSOR (state C)
			screen:blit(48,160, Cursor.img)

		end

bqstop=1





		  
	if qnumber==0 then

		if qnumber==0 then
		   -- load sounds
		   beforeq = Sound.load("sounds/selectsound.wav")
		   beforeq:play() 

		end

		if qnumber==0 then
		   qnumber=11111 
		end 
	end



	if qnumber==11111 then

		if qnumber==11111 then
		   -- load sounds
		   beforeq = Sound.load("sounds/q1.wav")
		   beforeq:play() 
		end

		if qnumber==11111 then
		   qnumber=1 
		end
		




--print question




	elseif qnumber == 1   then

		

		   
		





		screen:print(30,80, Question[1]   .q,white)
		screen:print(30,90, Question[1002].q,white)
		screen:print(30,100,Question[1003].q,white)
		screen:print(30,110,Question[1004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[1].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[1].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[1].c,white)

		correct = Question[1].cor

		if pad:start() then gamestate=0 end
	
	


	elseif qnumber == 2 then


		screen:print(30,80, Question[2]   .q,white)
		screen:print(30,90, Question[2002].q,white)
		screen:print(30,100,Question[2003].q,white)
		screen:print(30,110,Question[2004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[2].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[2].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[2].c,white)
		correct = Question[2].cor


		if pad:select() then
		screen:print(50,180, "Previous Answer #1:",white)

			if (Question[1].cor == 1) then
			screen:print(50,190, Question[1].a,white)

			elseif (Question[1].cor == 2) then
			screen:print(50,190, Question[1].b,white)

			else 
			screen:print(50,190, Question[1].c,white)
			end
		end if pad:start() then gamestate=0 end
		




			
		

	

	elseif qnumber == 3 then
		screen:print(30,80, Question[3]   .q,white)
		screen:print(30,90, Question[3002].q,white)
		screen:print(30,100,Question[3003].q,white)
		screen:print(30,110,Question[3004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[3].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[3].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[3].c,white)
		correct = Question[3].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #2:",white)

			if (Question[2].cor == 1) then
			screen:print(50,190, Question[2].a,white)
			elseif (Question[2].cor == 2) then
			screen:print(50,190, Question[2].b,white)
			else 
			screen:print(50,190, Question[2].c,white)
			end
		end if pad:start() then gamestate=0 end




	

	elseif qnumber == 4 then
		screen:print(30,80, Question[4]   .q,white)
		screen:print(30,90, Question[4002].q,white)
		screen:print(30,100,Question[4003].q,white)
		screen:print(30,110,Question[4004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[4].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[4].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[4].c,white)
		correct = Question[4].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #3:",white)

			if (Question[3].cor == 1) then
			screen:print(50,190, Question[3].a,white)

			elseif (Question[3].cor == 2) then
			screen:print(50,190, Question[3].b,white)

			else 
			screen:print(50,190, Question[3].c,white)
			end
		end if pad:start() then gamestate=0 end


	

	elseif qnumber == 5 then
		screen:print(30,80, Question[5]   .q,white)
		screen:print(30,90, Question[5002].q,white)
		screen:print(30,100,Question[5003].q,white)
		screen:print(30,110,Question[5004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[5].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[5].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[5].c,white)
		correct = Question[5].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #4:",white)

			if (Question[4].cor == 1) then
			screen:print(50,190, Question[4].a,white)

			elseif (Question[4].cor == 2) then
			screen:print(50,190, Question[4].b,white)

			else 
			screen:print(50,190, Question[4].c,white)
			end
		end if pad:start() then gamestate=0 end


	

	elseif qnumber == 6 then
		screen:print(30,80, Question[6]   .q,white)
		screen:print(30,90, Question[6002].q,white)
		screen:print(30,100,Question[6003].q,white)
		screen:print(30,110,Question[6004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[6].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[6].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[6].c,white)
		correct = Question[6].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #5:",white)

			if (Question[5].cor == 1) then
			screen:print(50,190, Question[5].a,white)

			elseif (Question[5].cor == 2) then
			screen:print(50,190, Question[5].b,white)

			else 
			screen:print(50,190, Question[5].c,white)
			end
		end if pad:start() then gamestate=0 end


	
	
	elseif qnumber == 7 then
		screen:print(30,80, Question[7]   .q,white)
		screen:print(30,90, Question[7002].q,white)
		screen:print(30,100,Question[7003].q,white)
		screen:print(30,110,Question[7004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[7].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[7].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[7].c,white)
		correct = Question[7].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #6:",white)

			if (Question[6].cor == 1) then
			screen:print(50,190, Question[6].a,white)

			elseif (Question[6].cor == 2) then
			screen:print(50,190, Question[6].b,white)

			else 
			screen:print(50,190, Question[6].c,white)
			end
		end if pad:start() then gamestate=0 end


	
	
	elseif qnumber == 8 then
		screen:print(30,80, Question[8]   .q,white)
		screen:print(30,90, Question[8002].q,white)
		screen:print(30,100,Question[8003].q,white)
		screen:print(30,110,Question[8004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[8].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[8].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[8].c,white)
		correct = Question[8].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #7:",white)

			if (Question[7].cor == 1) then
			screen:print(50,190, Question[7].a,white)

			elseif (Question[7].cor == 2) then
			screen:print(50,190, Question[7].b,white)

			else 
			screen:print(50,190, Question[7].c,white)
			end
		end if pad:start() then gamestate=0 end



		


	
	
	elseif qnumber == 9 then
		screen:print(30,80, Question[9]   .q,white)
		screen:print(30,90, Question[9002].q,white)
		screen:print(30,100,Question[9003].q,white)
		screen:print(30,110,Question[9004].q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[9].a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[9].b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[9].c,white)
		correct = Question[9].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #8:",white)

			if (Question[8].cor == 1) then
			screen:print(50,190, Question[8].a,white)

			elseif (Question[8].cor == 2) then
			screen:print(50,190, Question[8].b,white)

			else 
			screen:print(50,190, Question[8].c,white)
			end
		end if pad:start() then gamestate=0 end


	
	
	elseif qnumber == 10 then
		screen:print(30,80, Question[10]   .q,white)
		screen:print(30,90, Question[1002] .q,white)
		screen:print(30,100,Question[1003] .q,white)
		screen:print(30,110,Question[1004] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[10] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[10] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[10] .c,white)
		correct = Question[10].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #9:",white)

			if (Question[9].cor == 1) then
			screen:print(50,190, Question[9].a,white)

			elseif (Question[9].cor == 2) then
			screen:print(50,190, Question[9].b,white)

			else 
			screen:print(50,190, Question[9].c,white)
			end
		end if pad:start() then gamestate=0 end


	
	
	elseif qnumber == 11 then
		screen:print(30,80, Question[11]   .q,white)
		screen:print(30,90, Question[1102] .q,white)
		screen:print(30,100,Question[1103] .q,white)
		screen:print(30,110,Question[1104] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[11] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[11] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[11] .c,white)
		correct = Question[11].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #10:",white)

			if (Question[10].cor == 1) then
			screen:print(50,190, Question[10].a,white)

			elseif (Question[10].cor == 2) then
			screen:print(50,190, Question[10].b,white)

			else 
			screen:print(50,190, Question[10].c,white)
			end
		end if pad:start() then gamestate=0 end



	elseif qnumber == 12 then
		screen:print(30,80, Question[12]   .q,white)
		screen:print(30,90, Question[1202] .q,white)
		screen:print(30,100,Question[1203] .q,white)
		screen:print(30,110,Question[1204] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[12] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[12] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[12] .c,white)
		correct = Question[12].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #11:",white)

			if (Question[11].cor == 1) then
			screen:print(50,190, Question[11].a,white)

			elseif (Question[11].cor == 2) then
			screen:print(50,190, Question[11].b,white)

			else 
			screen:print(50,190, Question[11].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 13 then
		screen:print(30,80, Question[13]   .q,white)
		screen:print(30,90, Question[1302] .q,white)
		screen:print(30,100,Question[1303] .q,white)
		screen:print(30,110,Question[1304] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[13] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[13] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[13] .c,white)
		correct = Question[13].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #12:",white)

			if (Question[12].cor == 1) then
			screen:print(50,190, Question[12].a,white)

			elseif (Question[12].cor == 2) then
			screen:print(50,190, Question[12].b,white)

			else 
			screen:print(50,190, Question[12].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 14 then
		screen:print(30,80, Question[14]   .q,white)
		screen:print(30,90, Question[1402] .q,white)
		screen:print(30,100,Question[1403] .q,white)
		screen:print(30,110,Question[1404] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[14] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[14] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[14] .c,white)
		correct = Question[14].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #13:",white)

			if (Question[13].cor == 1) then
			screen:print(50,190, Question[13].a,white)

			elseif (Question[13].cor == 2) then
			screen:print(50,190, Question[13].b,white)

			else 
			screen:print(50,190, Question[13].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 15 then
		screen:print(30,80, Question[15]   .q,white)
		screen:print(30,90, Question[1502] .q,white)
		screen:print(30,100,Question[1503] .q,white)
		screen:print(30,110,Question[1504] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[15] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[15] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[15] .c,white)
		correct = Question[15].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #14:",white)

			if (Question[14].cor == 1) then
			screen:print(50,190, Question[14].a,white)

			elseif (Question[14].cor == 2) then
			screen:print(50,190, Question[14].b,white)

			else 
			screen:print(50,190, Question[14].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 16 then
		screen:print(30,80, Question[16]   .q,white)
		screen:print(30,90, Question[1602] .q,white)
		screen:print(30,100,Question[1603] .q,white)
		screen:print(30,110,Question[1604] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[16] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[16] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[16] .c,white)
		correct = Question[16].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #15:",white)

			if (Question[15].cor == 1) then
			screen:print(50,190, Question[15].a,white)

			elseif (Question[15].cor == 2) then
			screen:print(50,190, Question[15].b,white)

			else 
			screen:print(50,190, Question[15].c,white)
			end
		end if pad:start() then gamestate=0 end



	elseif qnumber == 17 then
		screen:print(30,80, Question[17]   .q,white)
		screen:print(30,90, Question[1702] .q,white)
		screen:print(30,100,Question[1703] .q,white)
		screen:print(30,110,Question[1704] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[17] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[17] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[17] .c,white)
		correct = Question[17].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #16:",white)

			if (Question[16].cor == 1) then
			screen:print(50,190, Question[16].a,white)

			elseif (Question[16].cor == 2) then
			screen:print(50,190, Question[16].b,white)

			else 
			screen:print(50,190, Question[16].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 18 then
		screen:print(30,80, Question[18]   .q,white)
		screen:print(30,90, Question[1802] .q,white)
		screen:print(30,100,Question[1803] .q,white)
		screen:print(30,110,Question[1804] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[18] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[18] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[18] .c,white)
		correct = Question[18].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #17:",white)

			if (Question[17].cor == 1) then
			screen:print(50,190, Question[17].a,white)

			elseif (Question[17].cor == 2) then
			screen:print(50,190, Question[17].b,white)

			else 
			screen:print(50,190, Question[17].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 19 then
		screen:print(30,80, Question[19]   .q,white)
		screen:print(30,90, Question[1902] .q,white)
		screen:print(30,100,Question[1903] .q,white)
		screen:print(30,110,Question[1904] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[19] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[19] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[19] .c,white)
		correct = Question[19].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #18:",white)

			if (Question[18].cor == 1) then
			screen:print(50,190, Question[18].a,white)

			elseif (Question[18].cor == 2) then
			screen:print(50,190, Question[18].b,white)

			else 
			screen:print(50,190, Question[18].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 20 then
		screen:print(30,80, Question[20]   .q,white)
		screen:print(30,90, Question[2002] .q,white)
		screen:print(30,100,Question[2003] .q,white)
		screen:print(30,110,Question[2004] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[20] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[20] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[20] .c,white)
		correct = Question[20].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #19:",white)

			if (Question[19].cor == 1) then
			screen:print(50,190, Question[19].a,white)

			elseif (Question[19].cor == 2) then
			screen:print(50,190, Question[19].b,white)

			else 
			screen:print(50,190, Question[19].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 21 then
		screen:print(30,80, Question[21]   .q,white)
		screen:print(30,90, Question[2102] .q,white)
		screen:print(30,100,Question[2103] .q,white)
		screen:print(30,110,Question[2104] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[21] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[21] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[21] .c,white)
		correct = Question[21].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #20:",white)

			if (Question[20].cor == 1) then
			screen:print(50,190, Question[20].a,white)

			elseif (Question[20].cor == 2) then
			screen:print(50,190, Question[20].b,white)

			else 
			screen:print(50,190, Question[20].c,white)
			end
		end if pad:start() then gamestate=0 end




	elseif qnumber == 22 then
		screen:print(30,80, Question[22]   .q,white)
		screen:print(30,90, Question[2202] .q,white)
		screen:print(30,100,Question[2203] .q,white)
		screen:print(30,110,Question[2204] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[22] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[22] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[22] .c,white)
		correct = Question[22].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #21:",white)

			if (Question[21].cor == 1) then
			screen:print(50,190, Question[21].a,white)

			elseif (Question[21].cor == 2) then
			screen:print(50,190, Question[21].b,white)

			else 
			screen:print(50,190, Question[21].c,white)
			end
		end if pad:start() then gamestate=0 end


	elseif qnumber == 23 then
		screen:print(30,80, Question[23]   .q,white)
		screen:print(30,90, Question[2302] .q,white)
		screen:print(30,100,Question[2303] .q,white)
		screen:print(30,110,Question[2304] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[23] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[23] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[23] .c,white)
		correct = Question[23].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #22:",white)

			if (Question[22].cor == 1) then
			screen:print(50,190, Question[22].a,white)

			elseif (Question[22].cor == 2) then
			screen:print(50,190, Question[22].b,white)

			else 
			screen:print(50,190, Question[22].c,white)
			end
		end if pad:start() then gamestate=0 end


	elseif qnumber == 24 then
		screen:print(30,80, Question[24]   .q,white)
		screen:print(30,90, Question[2402] .q,white)
		screen:print(30,100,Question[2403] .q,white)
		screen:print(30,110,Question[2404] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[24] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[24] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[24] .c,white)
		correct = Question[24].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #23:",white)

			if (Question[23].cor == 1) then
			screen:print(50,190, Question[23].a,white)

			elseif (Question[23].cor == 2) then
			screen:print(50,190, Question[23].b,white)

			else 
			screen:print(50,190, Question[23].c,white)
			end
		end if pad:start() then gamestate=0 end


	elseif qnumber == 25 then
		screen:print(30,80, Question[25]   .q,white)
		screen:print(30,90, Question[2502] .q,white)
		screen:print(30,100,Question[2503] .q,white)
		screen:print(30,110,Question[2504] .q,white)

		screen:print(50,140,"A:",white)
		screen:print(70,140,Question[25] .a,white)
		screen:print(50,150,"B:",white)
		screen:print(70,150,Question[25] .b,white)
		screen:print(50,160,"C:",white)
		screen:print(70,160,Question[25] .c,white)
		correct = Question[25].cor

		if pad:select() then
		screen:print(50,180, "Previous Answer #24:",white)

			if (Question[24].cor == 1) then
			screen:print(50,190, Question[24].a,white)

			elseif (Question[24].cor == 2) then
			screen:print(50,190, Question[24].b,white)

			else 
			screen:print(50,190, Question[24].c,white)
			end
		end if pad:start() then gamestate=0 end




		
	end
	




--print score
	screen:print(30,40,"Score:" .. score,white)
--print quiz name
	screen:print(30,30,Quizname,white)
	screen:print(30,50,"Question: " .. qnumber,white)
	movecursor()
	answer()
end

--------------------------------IF GAME ENDED
if gamestate == 0  then

	--blits
	screen:blit(0,0,bground) --bground
	screen:print(50,120,"You completed " .. Quizname .. ".",white)
	screen:print(50,130,"You got " .. score .. "  right.",white)
	screen:print(50,140,"You got " .. scorew .. " wrong.",white)
	screen:print(50,150,"Your score is " .. score .. "/"..score+scorew..".",white)



	--exit stuff
	screen:print(50,170,"Press Triangle or R to return to the main menu." ,white)

--trap exit button
	if pad:triangle() then
		dofile("./menu.lua")
		break
	end

end

--ending scripts
screen.waitVblankStart()
screen.flip()
end
