
-----------------------------------
abysspell
Thu Nov 02, 2006 8:53 am

Trivia Game
-----------------------------------
just a short trivia game i made, hope you like it


/********************************/
/*       Random Trivia Game               */
/*    this program will ask                  */
/*      the user 5 questions                */
/*    and will add a bonus one           */
/*     if the user chooses to.              */
/*    it will tally their score                 */
/*   and display it at the end.              */
/********************************/


% Variables
var any : string (1) % For the getch commands 
var font1, font2, font3 : int % For the fonts
var q1, q2, q3, q4, q5, bonus : string % The answers to the questions
var right, wrong, score : int := 0 % For the records
var name, risk : string

%Title Screen
%This will draw the shape of a paper bill
drawfillbox (0, 0, 700, 400, 23)
drawfillbox (0, 50, 700, 350, 2)
drawfilloval (315, 200, 240, 100, 6)
drawfillarc (0, 50, 50, 50, 0, 90, 6)
drawfillarc (0, 350, 50, 50, 270, 0, 6)
drawfillarc (639, 350, 50, 50, 180, 270, 6)
drawfillarc (639, 50, 50, 50, 90, 180, 6)

font1 := Font.New ("sans serif:20:italic")
font2 := Font.New ("sans serif:15:italic")
font3 := Font.New ("sans serif:13:italic")
assert font1 > 0
assert font2 > 0
Font.Draw ("   Welome To Random Trivia", 140, 192, font1, yellow)
Font.Draw ("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", 130, 222, font2, yellow)
Font.Draw ("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", 130, 162, font2, yellow)


locate (20, 30)
colorback (2)
put "Press Any Key To Play"
locate (21, 40)
getch (any)
cls

% Info Sheet
% This will inform the user of the quiz and ask him his name
Font.Draw ("This is Random Trivia, where you will try your luck at 5 of my toughest questions.", 0, 380, font3, yellow)
getch (any)
Font.Draw ("There is no real topic, so if you studied.....", 0, 360, font3, yellow)
getch (any)
Font.Draw ("you just waisted precious time.", 320, 360, font3, yellow)
getch (any)
Font.Draw ("Before we start, what is your name?", 0, 300, font3, yellow)
locate (10, 1)
get name
Font.Draw ("Well, now your ready to start, press any key to play, and good luck!", 0, 20, font3, yellow)
locate (24, 65)
getch (any)
cls



% Question 1
Font.Draw ("#1", 10, 350, font1, red)
Font.Draw ("What was the name of Super Man's pet monkey?", 50, 300, font2, red)
Font.Draw ("a) Bubbles", 70, 280, font3, red)
Font.Draw ("b) Junior", 70, 260, font3, red)
Font.Draw ("c) Beppo", 70, 240, font3, red)
Font.Draw ("d) Fred", 70, 220, font3, red)
locate (15, 10)
get q1


if q1 = "c"
        then
    Font.Draw ("CORRECT!!! How did you know that?", 70, 140, font3, red)
    right := right + 1
    score := score + 1
else
    Font.Draw ("Sorry, wrong answer. The correct answer is c) Beppo.", 70, 140, font3, red)
    wrong := wrong + 1
    score := score - 1
end if

locate (20, 30)
colorback (2)
put "Press Any Key To Continue"
locate (21, 40)
getch (any)
cls



% Question 2
Font.Draw ("#2", 10, 350, font1, red)
Font.Draw ("What fruit has 50% the same genetic information as humans?", 50, 300, font2, red)
Font.Draw ("*Hint: This Fruit was also banned in the Middle East", 50, 280, font2, red)
Font.Draw ("a) Apple", 70, 260, font3, red)
Font.Draw ("b) Banana", 70, 240, font3, red)
Font.Draw ("c) Kiwi", 70, 220, font3, red)
Font.Draw ("d) Peach", 70, 200, font3, red)
locate (15, 10)
get q2

if q2 = "b"
        then
    Font.Draw ("Wow, you got it right!", 70, 140, font3, red)
    wrong := wrong + 1
    score := score + 1
else
    Font.Draw ("Sorry, you got it wrong. The correct answer is b) Banana.", 70, 140, font3, red)
    right := right + 1
    score := score - 1
end if

locate (20, 30)
colorback (2)
put "Press Any Key To Continue"
locate (21, 40)
getch (any)
cls



% Question 3
Font.Draw ("#3", 10, 350, font1, red)
Font.Draw ("What are Dr. Jackyll's and Mr. Hydes's first names?", 50, 300, font2, red)
Font.Draw ("a) Bob and Luke", 70, 280, font3, red)
Font.Draw ("b) Joe and Mike", 70, 260, font3, red)
Font.Draw ("c) Henry end Edward", 70, 240, font3, red)
Font.Draw ("d) Robert and Fred", 70, 220, font3, red)
locate (15, 10)
get q3

if q3 = "c"
        then
    Font.Draw ("Thats the right answer, congats!", 70, 140, font3, red)
    wrong := wrong + 1
    score := score + 1
else
    Font.Draw ("You were wrong . The correct answer is c) Henery and Edward.", 70, 140, font3, red)
    wrong := wrong + 1
    score := score - 1
end if

locate (20, 30)
colorback (2)
put "Press Any Key To Continue"
locate (21, 40)
getch (any)
cls



% Question 4
Font.Draw ("#4", 10, 350, font1, red)
Font.Draw ("What bird can fly upside down?", 50, 300, font2, red)
Font.Draw ("a) Parrot", 70, 280, font3, red)
Font.Draw ("b) Blue Bird", 70, 260, font3, red)
Font.Draw ("c) Pigeon", 70, 240, font3, red)
Font.Draw ("d) Humming Bird", 70, 220, font3, red)
locate (15, 10)
get q4

if q4 = "d"
        then
    Font.Draw ("That was to easy! You got it right!", 70, 140, font3, red)
    wrong := wrong + 1
    score := score + 1
else
    Font.Draw ("Thats the wrong answer. The correct one was d) Humming Bird.", 70, 140, font3, red)
    wrong := wrong + 1
    score := score - 1
end if

locate (20, 30)
colorback (2)
put "Press Any Key To Continue"
locate (21, 40)
getch (any)
cls



% Question 5
Font.Draw ("#5", 10, 350, font1, red)
Font.Draw ("What is the easiest sound for the human ear to hear?", 50, 300, font2, red)
Font.Draw ("a) eh", 70, 280, font3, red)
Font.Draw ("b) ah", 70, 260, font3, red)
Font.Draw ("c) yes", 70, 240, font3, red)
Font.Draw ("d) shhh", 70, 220, font3, red)
locate (15, 10)
get q5

if q5 = "b"
        then
    Font.Draw ("Ah, I see that your smart, you got it right!", 70, 140, font3, red)
    wrong := wrong + 1
    score := score + 1
else
    Font.Draw ("Wrong, the correct answer is b) ah", 70, 140, font3, red)
    right := right + 1
    score := score - 1
end if


locate (20, 30)
colorback (2)
put "Press Any Key To Continue"
locate (21, 40)
getch (any)
cls




%Bonus
% This will give the user an option to take a bonus question for extra points
Font.Draw ("You have completed The Random Trivia Game!", 10, 380, font2, yellow)
delay (900)
Font.Draw ("But wait, theres more!", 10, 350, font2, yellow)
delay (900)
Font.Draw ("If you want, you could take a bonus question.", 10, 320, font2, yellow)
delay (900)
Font.Draw ("If you get it right, you will get 2 points,", 10, 290, font2, yellow)
delay (900)
Font.Draw ("If you get it wrong, you will loose 2 points.", 10, 260, font2, yellow)
delay (900)
Font.Draw ("So are you willing to take the risk? y/n.", 10, 230, font2, yellow)
locate (20, 1)
get risk

if risk = "y"
        then
    Font.Draw ("Ok, good luck to you, press any key", 10, 50, font2, yellow)
    getch (any)
    cls
    Font.Draw ("In 1740, what animal did a French judge find guilty of sorcery?", 50, 300, font2, yellow)
    Font.Draw ("a) Sheep", 70, 280, font3, yellow)
    Font.Draw ("b) Cow", 70, 260, font3, yellow)
    Font.Draw ("c) Horse", 70, 240, font3, yellow)
    Font.Draw ("d) Goat", 70, 220, font3, yellow)
    locate (15, 10)
    get bonus

    if bonus = "b"
            then
        Font.Draw ("WOW! Your smart, or was it a lucky guess? Congrats!", 70, 140, font3, yellow)
        wrong := wrong + 1
        score := score - 2
    else
        Font.Draw ("OOOO! Bummer. Thats the wrong answer. The correct one was b) Cow", 70, 140, font3, yellow)
        right := right + 1
        score := score + 2
    end if

    locate (20, 20)
    colorback (2)
    put "Press Any Key To See Your Score"
    locate (21, 40)
    getch (any)
    cls

    put "Lets look at your records ", name, "......"
    delay (900)
    put "Your score is: ", score
    put "You answered ", wrong, " question(s) wrong."
    put "You answered ", right, " question(s) right."

    put "Press Any Key To Finish"
    locate (21, 40)
    getch (any)
    cls

    Font.Draw ("Thanks for playing the Random Trivia Game!", 50, 192, font1, yellow)
    Font.Draw ("I hope you learned something.", 165, 165, font1, yellow)
    
elsif risk = "n"
        then
    Font.Draw ("Not a risk taker I see, o well, press any key to see you score.", 10, 50, font2, yellow)
    getch (any)
    cls

    put "Lets look at your records ", name, "......"
    delay (2500)
    put "Your score is: ", score
    put "You answered ", wrong, " questions wrong."
    put "You answered ", right, " questions right."
    delay (2500)
    put "Press Any Key To Finish"
    locate (21, 40)
    getch (any)
    cls

    
    Font.Draw ("Thanks for playing the Random Trivia Game!", 50, 192, font1, yellow)
    Font.Draw ("I hope you learned something.", 165, 165, font1, yellow)
end if



/******************/
/*   End Of Program   */
/******************/

-----------------------------------
Mathwiz
Thu Nov 02, 2006 8:56 am

that was good
-----------------------------------
that was good make  sure it does not crap out

-----------------------------------
Clayton
Thu Nov 02, 2006 10:48 am


-----------------------------------
hmmm. Get rid of the delays everywhere. I don't feel like waiting 2 seconds between every line of text. Especially since I am a fast reader. Have some sort of "Press any key to continue" Thing after a block of text. Also, I'm sure you can put procedures/functions to use here, have some sort of function to take the question, answer and input and see if they answered correctly. That way, you will end up with a lot less coding and a lot of saved space.

EDIT: Next time use the [code][/code] tags when posting code please, that way your code keeps its indentation, plus it's easier to read. ;)

-----------------------------------
abysspell
Thu Nov 02, 2006 2:13 pm


-----------------------------------
Thanks for the tips, I'll try to modify it later. :D

-----------------------------------
bruized
Thu Nov 02, 2006 7:01 pm


-----------------------------------
Just as another little tip, you should slightly modify your if statement. Instead of checking for every single wrong answer, you should just check for the right answer then use the else statement and anything that's not the right answer will be shown that (especially since all your wrong answers are shown the exact same thing).

As an example. Instead of

If ans = a then
put "correct"
elsif ans = b then
put "incorrect"
elsif ans = c then
put "incorrect"
...

and so on

you could put

if ans = a then
put "correct"
else
put "incorrect"

It just helps in keeping the code neater and having less unneeded code.

-----------------------------------
abysspell
Fri Nov 03, 2006 9:24 am


-----------------------------------
That would be smart! I can't beleive i didnt think of that! :shock:  :roll:  man im stupid

-----------------------------------
Mathwiz
Mon Nov 06, 2006 8:33 am

Re: that was good
-----------------------------------
that was good make  sure it does not crap out

ben ben ben when you ask the user 



 
Font.Draw ("So are you willing to take the risk? y/n."

 and they put a capital letter it stops you sould change that...

-----------------------------------
abysspell
Mon Nov 06, 2006 8:51 am


-----------------------------------
ok, its all fixed up now so it should run smoothly. and its 70 lines shorter! YAY!

-----------------------------------
gameover
Tue Dec 05, 2006 11:01 pm


-----------------------------------
:D Like your program alot i had a similar one but its kinda messy but i think ur program would look better if u were to say make it possible to click on the answer rather than type the answer like amke the choices clickable :)

-----------------------------------
gameover
Wed Dec 06, 2006 7:24 pm


-----------------------------------
BTW your score doesnt add up u made some mistakes with that like u switched the variable wrong and right in some places or used the wrong calculation sign like + instead of - :)
