Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Trivia game summative help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
progger5




PostPosted: Thu Jun 02, 2005 9:55 am   Post subject: Trivia game summative help

I am making a trivia game for my isu and i need help with the code. I have no idea how to include a counter for the correct questions. I also need to know how to make the questions random. Question


setscreen ("graphics")
setscreen ("graphics:800;500")
setscreen ("nocursor")
var answer16,answer17, answer18, answer19, answer20, answer21, answer22, answer23, answer24, answer25: string
var fontID20 : int := Font.New ("Arial:16:bold")
%**************Question 16************
colorback (white)
cls
var pic16 : int := Pic.FileNew ("al.jpg")
Pic.Draw (pic16, 0, -10, picMerge)
Font.Draw ("In what 1972 mafia movie did Al pacino play in?", 19, 465,fontID20, 89)
Font.Draw ("A. Goodfellas", 165, 390, fontID20, 96)
Font.Draw ("B. Scarface", 165, 370, fontID20, 96)
Font.Draw ("C. The Italian Job", 165, 350, fontID20, 96)
Font.Draw ("D. The Godfather", 165, 330, fontID20, 96)
get answer16
if answer16 = "d" or answer16 = "D" or answer16 = "d)" or answer16 = "D)"
then
cls
Pic.Draw (pic16, 0, 0, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 89)
delay (1500)
else
cls
Pic.Draw (pic16, 0, 0, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 89)
delay (1500)
end if
cls
delay (500)

%*************Question #17*******************
colorback (77)
cls
var pic17 : int := Pic.FileNew ("soccer.jpg")
Pic.Draw (pic17, 0, -10, picMerge)
Font.Draw ("How often does the world cup take place?", 150, 465, fontID20, 79)
Font.Draw ("A. Annually", 270, 390, fontID20, 48)
Font.Draw ("B. Every four years", 270, 370, fontID20, 48)
Font.Draw ("C. Once in a while", 270, 350, fontID20, 48)
Font.Draw ("D. Every eight years", 270, 330, fontID20, 48)
get answer17
if answer17 = "b" or answer17 = "B" or answer17 = "b)" or answer17 = "B)"
then
cls
Pic.Draw (pic17, 0, -10, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20,48)
delay (1500)
else
cls
Pic.Draw (pic17, 0, -10, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 48)
delay (1500)
end if
%************Question #18***********
colorback (white)
cls
var pic18 : int := Pic.FileNew ("simeonee.jpg")
Pic.Draw (pic18, 30, 20, picMerge)
Font.Draw ("Who captained Argentina at World Cup 1998?", 9, 475, fontID20,53)
Font.Draw ("A. Hulio Flores", 105, 370, fontID20, 104)
Font.Draw ("B. Diego Simeone", 105, 350, fontID20, 104)
Font.Draw ("C. Carlos Tevez", 105, 330, fontID20, 104)
Font.Draw ("D. Pablo Aimar", 105, 310, fontID20, 104)
get answer18
if answer18 = "b" or answer18 = "B" or answer18 = "b)" or answer18 = "B)"
then
cls
Pic.Draw (pic18, 0, 40, picMerge)
Font.Draw ("CORRECT!!!", 295, 390, fontID20, 53)
delay (1500)
else
cls
Pic.Draw (pic18, 0, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 53)
delay (1500)
end if
%*********Question #19************
colorback (white)
cls
var pic19 : int := Pic.FileNew ("i.jpg")
Pic.Draw (pic19, 0, -90, picMerge)
Font.Draw ("Italy last won the World Cup in", 9, 465, fontID20, 12)
Font.Draw ("A. 1974", 165, 370, fontID20, 31)
Font.Draw ("B. 1990", 165, 350, fontID20, 2)
Font.Draw ("C. 1982", 165, 330, fontID20, 31)
Font.Draw ("D. 2002", 165, 300, fontID20, 2)
get answer19
if answer19 = "c" or answer19 = "C" or answer19 = "c)" or answer19 = "C)"
then
cls
Pic.Draw (pic19, 0, -90, picMerge)
Font.Draw ("CORRECT!!!", 295, 380, fontID20, 12)
delay (1500)
else
cls
Pic.Draw (pic19, 0, -90, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 340, fontID20, 12)
delay (1500)
end if
%**************Question #20*************************
colorback (white)
cls
var pic20 : int := Pic.FileNew ("world.jpg")
Pic.Draw (pic20, 0, 0, picMerge)
Font.Draw ("Which country besieds Brazil has won the World Cup back to back?", 9, 465, fontID20, 55)
Font.Draw ("A. Italy", 105, 370, fontID20, white)
Font.Draw ("B. Germany", 105, 350, fontID20, white)
Font.Draw ("C. Uruguay", 105, 330, fontID20, white)
Font.Draw ("D. Portugal", 105, 310, fontID20, white)
get answer20
if answer20 = "a" or answer20 = "A" or answer20 = "a)" or answer20 = "A)"
then
cls
Pic.Draw (pic20, 0, 20, picMerge)
Font.Draw ("CORRECT!!!", 295, 390, fontID20, white)
delay (1500)
else
cls
Pic.Draw (pic20, 0, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, white)
delay (1500)
end if

%*********Question #21*****************
colorback (black)
cls
var pic21 : int := Pic.FileNew ("ter.jpg")
Pic.Draw (pic21, 0, 20, picMerge)
Font.Draw ("In 1998 the Denver Broncos won Superbowl XXXII. Who was there MVP?", 9, 465, fontID20, 66)
Font.Draw ("A. John Elway", 165, 390, fontID20, 115)
Font.Draw ("B. Jerry Rice", 165, 370, fontID20, 115)
Font.Draw ("C. Terrell Davis", 165, 350, fontID20, 115)
Font.Draw ("D. Terry Bradshaw", 165, 330, fontID20, 115)
get answer21
if answer21 = "c" or answer21 = "C" or answer21 = "c)" or answer21 = "C)"
then
cls
Pic.Draw (pic21,0, 20, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 66)
delay (1500)
else
cls
Pic.Draw (pic21, 0, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 66)
delay (1500)
end if
%***************Question #22*****************
colorback (black)
cls
var pic22 : int := Pic.FileNew ("ring.jpg")
Pic.Draw (pic22, 0, -30, picMerge)
Font.Draw ("The third installment of the Lord of the Rings was directed by:", 9, 465, fontID20, 65)
Font.Draw ("A. Steven Spielburg", 195, 290, fontID20, 67)
Font.Draw ("B. J.R.R. Tolkien", 195, 270, fontID20, 67)
Font.Draw ("C. Ian McKellan", 195, 250, fontID20, 67)
Font.Draw ("D. Peter Jackson", 195, 230, fontID20, 67)
get answer22
if answer22 = "d" or answer22 = "D" or answer22 = "d)" or answer22 = "D)"
then
cls
Pic.Draw (pic22, 0, -30, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 67)
delay (1500)
else
cls
Pic.Draw (pic22, 0, -30, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 67)
delay (1500)
end if
%***********Question #23**********
colorback (63)
cls
var pic23: int := Pic.FileNew ("fire.jpg")
Pic.Draw (pic23, 20, 20, picMerge)
Font.Draw ("In the 1993 movie Mrs. Doubtfire, Robin Williams played a father, and:", 9, 465, fontID20, white)
Font.Draw ("A. An Elderly Thief", 125, 270, fontID20, white)
Font.Draw ("B. A Babysitter", 125, 250, fontID20, white)
Font.Draw ("C. A police officer", 125, 230, fontID20, white)
Font.Draw ("D. A Teacher", 125, 200, fontID20, white)
get answer23
if answer23 = "b" or answer23 = "B" or answer23 = "b)" or answer23 = "B)"
then
cls
Pic.Draw (pic23, 20, 20, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
delay (1500)
else
cls
Pic.Draw (pic23, 20, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 230, 350, fontID20, 55)
delay (1500)
end if
%*************Question #24******************
colorback (9)
cls
var pic24 : int := Pic.FileNew ("ball.jpg")
Pic.Draw (pic24, 20, 20, picMerge)
Font.Draw ("In the Pistons - Pacers brawl of November, one of the players involved was:", 9, 465, fontID20, 55)
Font.Draw ("A. Ron Artest", 125, 350, fontID20, 12)
Font.Draw ("B. Rick Carlisle", 125, 330, fontID20, 12)
Font.Draw ("C. Morris Peterson", 125, 300, fontID20, 12)
Font.Draw ("D. Roman Kabanov", 125, 270, fontID20, 12)
get answer24
if answer24 = "a" or answer24 = "A" or answer24 = "a)" or answer24 = "A)"
then
cls
Pic.Draw (pic24, 0, 20, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
delay (1500)
else
cls
Pic.Draw (pic24, 0, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 55)
delay (1500)
end if
%******************Question #25*********
colorback (black)
cls
var pic25 : int := Pic.FileNew ("co.jpg")
Pic.Draw (pic25, 20, 20, picMerge)
Font.Draw ("In 1994 a rock star was found dead in his Seattle home. His name was", 9, 465, fontID20, 55)
Font.Draw ("A. Chad Kroeger", 165, 290, fontID20, 43)
Font.Draw ("B. Dave Navarro", 165, 270, fontID20, 43)
Font.Draw ("C. Anthony Kiedis", 165, 250, fontID20, 43)
Font.Draw ("D. Kurt Cobain", 165, 230, fontID20, 43)
get answer25
if answer25 = "d" or answer25 = "D" or answer25 = "d)" or answer25 = "D)"
then
cls
Pic.Draw (pic25, 0, 20, picMerge)
Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
delay (1500)
else
cls
Pic.Draw (pic25, 0, 20, picMerge)
Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 55)
delay (1500)
end if
Sponsor
Sponsor
Sponsor
sponsor
BitHoarder




PostPosted: Thu Jun 02, 2005 10:17 am   Post subject: Re: Trivia game summative help

[quote="progger5"]I am making a trivia game for my isu and i need help with the code. I have no idea how to include a counter for the correct questions. I also need to know how to make the questions random. Question
code:


setscreen ("graphics")
setscreen ("graphics:800;500")
setscreen ("nocursor")
var answer16,answer17, answer18, answer19, answer20, answer21, answer22, answer23, answer24, answer25: string
var fontID20 : int := Font.New ("Arial:16:bold")
%**************Question 16************
colorback (white)
cls
var pic16 : int := Pic.FileNew ("al.jpg")
Pic.Draw (pic16, 0, -10, picMerge)
Font.Draw ("In what 1972 mafia movie did Al pacino play in?", 19, 465,fontID20, 89)
Font.Draw ("A. Goodfellas", 165, 390, fontID20, 96)
Font.Draw ("B. Scarface", 165, 370, fontID20, 96)
Font.Draw ("C. The Italian Job", 165, 350, fontID20, 96)
Font.Draw ("D. The Godfather", 165, 330, fontID20, 96)
get answer16
if answer16 = "d" or answer16 = "D" or answer16 = "d)" or answer16 = "D)"
then
    cls
    Pic.Draw (pic16, 0, 0, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 89)
    delay (1500)
else
    cls
    Pic.Draw (pic16, 0, 0, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 89)
    delay (1500)
end if
cls
delay (500)

%*************Question #17*******************
colorback (77)
cls
var pic17 : int := Pic.FileNew ("soccer.jpg")
Pic.Draw (pic17, 0, -10, picMerge)
Font.Draw ("How often does the world cup take place?", 150, 465, fontID20, 79)
Font.Draw ("A. Annually", 270, 390, fontID20, 48)
Font.Draw ("B. Every four years", 270, 370, fontID20, 48)
Font.Draw ("C. Once in a while", 270, 350, fontID20, 48)
Font.Draw ("D. Every eight years", 270, 330, fontID20, 48)
get answer17
if answer17 = "b" or answer17 = "B" or answer17 = "b)" or answer17 = "B)"
then
    cls
Pic.Draw (pic17, 0, -10, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20,48)
    delay (1500)
else
    cls
    Pic.Draw (pic17, 0, -10, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 48)
    delay (1500)
end if
%************Question #18***********
colorback (white)
cls
var pic18 : int := Pic.FileNew ("simeonee.jpg")
Pic.Draw (pic18, 30, 20, picMerge)
Font.Draw ("Who captained Argentina at World Cup 1998?", 9, 475, fontID20,53)
Font.Draw ("A. Hulio Flores", 105, 370, fontID20, 104)
Font.Draw ("B. Diego Simeone", 105, 350, fontID20, 104)
Font.Draw ("C. Carlos Tevez", 105, 330, fontID20, 104)
Font.Draw ("D. Pablo Aimar", 105, 310, fontID20, 104)
get answer18
if answer18 = "b" or answer18 = "B" or answer18 = "b)" or answer18 = "B)"
then
    cls
    Pic.Draw (pic18, 0, 40, picMerge)
    Font.Draw ("CORRECT!!!", 295, 390, fontID20, 53)
    delay (1500)
else
    cls
    Pic.Draw (pic18, 0, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 53)
    delay (1500)
end if
%*********Question #19************
colorback (white)
cls
var pic19 : int := Pic.FileNew ("i.jpg")
Pic.Draw (pic19, 0, -90, picMerge)
Font.Draw ("Italy last won the World Cup in", 9, 465, fontID20, 12)
Font.Draw ("A. 1974", 165, 370, fontID20, 31)
Font.Draw ("B. 1990", 165, 350, fontID20, 2)
Font.Draw ("C. 1982", 165, 330, fontID20, 31)
Font.Draw ("D. 2002", 165, 300, fontID20, 2)
get answer19
if answer19 = "c" or answer19 = "C" or answer19 = "c)" or answer19 = "C)"
then
    cls
Pic.Draw (pic19, 0, -90, picMerge)
    Font.Draw ("CORRECT!!!", 295, 380, fontID20, 12)
    delay (1500)
else
    cls
    Pic.Draw (pic19, 0, -90, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 340, fontID20, 12)
    delay (1500)
end if
%**************Question #20*************************
colorback (white)
cls
var pic20 : int := Pic.FileNew ("world.jpg")
Pic.Draw (pic20, 0, 0, picMerge)
Font.Draw ("Which country besieds Brazil has won the World Cup back to back?", 9, 465, fontID20, 55)
Font.Draw ("A. Italy", 105, 370, fontID20, white)
Font.Draw ("B. Germany", 105, 350, fontID20, white)
Font.Draw ("C. Uruguay", 105, 330, fontID20, white)
Font.Draw ("D. Portugal", 105, 310, fontID20, white)
get answer20
if answer20 = "a" or answer20 = "A" or answer20 = "a)" or answer20 = "A)"
then
    cls
    Pic.Draw (pic20, 0, 20, picMerge)
    Font.Draw ("CORRECT!!!", 295, 390, fontID20, white)
    delay (1500)
else
    cls
    Pic.Draw (pic20, 0, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, white)
    delay (1500)
end if

%*********Question #21*****************
colorback (black)
cls
var pic21 : int := Pic.FileNew ("ter.jpg")
Pic.Draw (pic21, 0, 20, picMerge)
Font.Draw ("In 1998 the Denver Broncos won Superbowl XXXII.  Who was there MVP?", 9, 465, fontID20, 66)
Font.Draw ("A. John Elway", 165, 390, fontID20, 115)
Font.Draw ("B. Jerry Rice", 165, 370, fontID20, 115)
Font.Draw ("C. Terrell Davis", 165, 350, fontID20, 115)
Font.Draw ("D. Terry Bradshaw", 165, 330, fontID20, 115)
get answer21
if answer21 = "c" or answer21 = "C" or answer21 = "c)" or answer21 = "C)"
then
    cls
    Pic.Draw (pic21,0, 20, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 66)
    delay (1500)
else
    cls
    Pic.Draw (pic21, 0, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 66)
    delay (1500)
end if
%***************Question #22*****************
colorback (black)
cls
var pic22 : int := Pic.FileNew ("ring.jpg")
Pic.Draw (pic22, 0, -30, picMerge)
Font.Draw ("The third installment of the Lord of the Rings was directed by:", 9, 465, fontID20, 65)
Font.Draw ("A. Steven Spielburg", 195, 290, fontID20, 67)
Font.Draw ("B. J.R.R. Tolkien", 195, 270, fontID20, 67)
Font.Draw ("C. Ian McKellan", 195, 250, fontID20, 67)
Font.Draw ("D. Peter Jackson", 195, 230, fontID20, 67)
get answer22
if answer22 = "d" or answer22 = "D" or answer22 = "d)" or answer22 = "D)"
then
    cls
    Pic.Draw (pic22, 0, -30, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 67)
    delay (1500)
else
    cls
    Pic.Draw (pic22, 0, -30, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 67)
    delay (1500)
end if
%***********Question #23**********
colorback (63)
cls
var pic23: int := Pic.FileNew ("fire.jpg")
Pic.Draw (pic23, 20, 20, picMerge)
Font.Draw ("In the 1993 movie Mrs. Doubtfire, Robin Williams played a father, and:", 9, 465, fontID20, white)
Font.Draw ("A. An Elderly Thief", 125, 270, fontID20, white)
Font.Draw ("B. A Babysitter", 125, 250, fontID20, white)
Font.Draw ("C. A police officer", 125, 230, fontID20, white)
Font.Draw ("D. A Teacher", 125, 200, fontID20, white)
get answer23
if answer23 = "b" or answer23 = "B" or answer23 = "b)" or answer23 = "B)"
then
    cls
Pic.Draw (pic23, 20, 20, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
    delay (1500)
else
    cls
    Pic.Draw (pic23, 20, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 230, 350, fontID20, 55)
    delay (1500)
end if
%*************Question #24******************
colorback (9)
cls
var pic24 : int := Pic.FileNew ("ball.jpg")
Pic.Draw (pic24, 20, 20, picMerge)
Font.Draw ("In the Pistons - Pacers brawl of November, one of the players involved was:", 9, 465, fontID20, 55)
Font.Draw ("A. Ron Artest", 125, 350, fontID20, 12)
Font.Draw ("B. Rick Carlisle", 125, 330, fontID20, 12)
Font.Draw ("C. Morris Peterson", 125, 300, fontID20, 12)
Font.Draw ("D. Roman Kabanov", 125, 270, fontID20, 12)
get answer24
if answer24 = "a" or answer24 = "A" or answer24 = "a)" or answer24 = "A)"
then
    cls
    Pic.Draw (pic24, 0, 20, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
    delay (1500)
else
    cls
    Pic.Draw (pic24, 0, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 55)
    delay (1500)
end if
%******************Question #25*********
colorback (black)
cls
var pic25 : int := Pic.FileNew ("co.jpg")
Pic.Draw (pic25, 20, 20, picMerge)
Font.Draw ("In 1994 a rock star was found dead in his Seattle home. His name was", 9, 465, fontID20, 55)
Font.Draw ("A. Chad Kroeger", 165, 290, fontID20, 43)
Font.Draw ("B. Dave Navarro", 165, 270, fontID20, 43)
Font.Draw ("C. Anthony Kiedis", 165, 250, fontID20, 43)
Font.Draw ("D. Kurt Cobain", 165, 230, fontID20, 43)
get answer25
if answer25 = "d" or answer25 = "D" or answer25 = "d)" or answer25 = "D)"
then
    cls
Pic.Draw (pic25, 0, 20, picMerge)
    Font.Draw ("CORRECT!!!", 295, 400, fontID20, 55)
    delay (1500)
else
    cls
    Pic.Draw (pic25, 0, 20, picMerge)
    Font.Draw ("Sorry, but you are incorrect.", 240, 350, fontID20, 55)
    delay (1500)
end if[/quote]


Talk about a shitty code
Tony




PostPosted: Thu Jun 02, 2005 2:24 pm   Post subject: (No subject)

so much hard code... Shocked

you'd want to count how many times you've displayed Font.Draw ("CORRECT!!!", 295, 400, fontID20, *) though.
MysticVegeta




PostPosted: Fri Jun 03, 2005 3:24 pm   Post subject: (No subject)

Make 2 procedures:

code:

proc cor
   put "YOU ARE CORRECT!"
end cor


and

code:
proc wro
put " YOU ARE WRONG!"
end wro


then back to the question
code:
if guess = answer then
cor
else
wro
end if


For a counter, You need to make an interger that will count how many times the person has answered correctly:

code:
var counter: int := 0
if guess = answer then
cor
counter += 1
else
wro
end if


And then in the end you can display ->

code:
put "You have answered correctly ", counter, " times!!!"
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: