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

Username:   Password: 
 RegisterRegister   
 A jepordy triva game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
petree08




PostPosted: Mon Oct 01, 2007 11:16 am   Post subject: A jepordy triva game

this is a jepordy thingy .
the questions are for a english project i had to do
You could probably change the questions
i know i shoould have loaded them from a file but eh"


code:
procedure Question_Ask (Question : string, Player : nat1, var Score1,
        Score2 : int, Font1, C, Price : int, var Asked : boolean)
    var Answer : char
    Input.Flush
    Font.Draw (Question, 1, maxy - 200, Font1, C)
    View.Update
    Answer := getchar
    if Answer = "1" then
        Font.Draw ("Correct!", maxx div 2, maxy div 2, Font1, 10)
        if Player = 1 then

            Score1 := Score1 + Price
        else
            Score2 := Score2 + Price

        end if
    else
        if Player = 1 then

            Score1 := Score1 - Price
        else
            Score2 := Score2 - Price

        end if


        Font.Draw ("Incorrect!", maxx div 2, maxy div 2, Font1, 12)

    end if
    if Answer = "1" or Answer = "r" then
        Asked := true
    end if
    View.Update
    delay (1000)
end Question_Ask
setscreen ("graphics:max,max,nobuttonbar,offscreenonly,nocursor")

const NUM_OF_QS := 15
var Turn : nat1
var Question : array 1 .. NUM_OF_QS of string (100)
var XQ, YQ, Cost : array 1 .. NUM_OF_QS of int
var Asked : array 1 .. NUM_OF_QS of boolean

var XM, YM, Click : int
var Score1, Score2 : int
var DrawCount : int
var Font1, Font2 : int
var PriceN : int

var A : char
var Name1, Name2 : string (10)
var QuestionCount : nat1

%These are the questions
% note they are in a weird order because
% they are organized by catagory and
% not by thier number in the array


%PLOT

Question (1) := "What weapon does Purvis use to murder people?"
Question (4) := "What animals were being killed during the three days " +
    "of rain? (OMWEW)"
Question (7) := "What building is all of the duplicated books in?(IL)"
Question (10) := "What happens to the 'old drunk' (Purvis)"
Question (13) := "What guns are used to kill the monkeys? (IL)"
% Authors
Question (2) := "Name any author not in this phase."
Question (5) := "Who wrote Inflexible Logic?"
Question (8) := "Who wrote Purvis?"
Question (11) := "Who wrote A Very Old Man with Enormous Wings?"
Question (14) := "Who translated AVOMWEW?"


%"Characters

Question (3) := "Purvis"
Question (6) := "Mr Bainbridge"
Question (9) := "Pelayo"
Question (12) := "Young"
Question (15) := "Bill"

Font1 := Font.New ("System:30")
Font2 := Font.New ("System:18")

QuestionCount := 0
DrawCount := 0
Turn := 1
Score1 := 0
Score2 := 0

PriceN := 100
SX := 200
SY := maxy - 200

colorback (7)
cls
Font.Draw ("Peter Watt's, simple standard trivia game", 1, maxy - 100, Font1, 0)
Font.Draw ("Press any key to advance", 100, 100, Font2, 10)
View.Update
A := getchar
colorback (9)
cls
loop
    DrawCount := DrawCount + 1
    Asked (DrawCount) := false
    XQ (DrawCount) := SX + 100
    YQ (DrawCount) := SY
    drawbox (XQ (DrawCount) - 100, YQ (DrawCount) - 50,
        XQ (DrawCount) + 100, YQ (DrawCount) + 50, 1)
    Cost (DrawCount) := PriceN

    Font.Draw (natstr (Cost (DrawCount)), XQ (DrawCount), YQ (DrawCount),
        Font1, 12)
    SX := SX + 200
    if SX >= maxx - 300 then
        PriceN := PriceN + 100
        SX := 200
        SY := SY - 100
    end if

    exit when DrawCount >= NUM_OF_QS

end loop
%

loop


    cls

    mousewhere (XM, YM, Click)

    for I : 1 .. NUM_OF_QS
        if XM < XQ (I) + 100 and XM > XQ (I) - 100 and YM < YQ (I) + 50 and
                YM > YQ (I) - 50 then

            drawfillbox (XQ (I) - 100, YQ (I) - 50, XQ (I) + 100,
                YQ (I) + 50,
                1)

            if Click = 1 then

                if not Asked (I) then
                    cls
                    %  Question_Ask (Question : string, Player : nat1, var Score1,
                    %   Score2 : int, Font1, C, Price : int, var Asked : boolean)
                    Question_Ask (Question (I), Turn, Score1, Score2, Font2, 0, Cost (I),
                        Asked (I))
                    if Asked (I) then
                        QuestionCount := QuestionCount + 1
                    end if
                    if Turn = 1 then
                        Turn := 2
                    else
                        Turn := 1
                    end if

                    % Asked (I) := true
                end if
            end if
        end if
        drawbox (XQ (I) - 100, YQ (I) - 50, XQ (I) + 100, YQ (I) + 50, 0)
        if not Asked (I) then
            Font.Draw ("$" + natstr (Cost (I)), XQ (I) - 50, YQ (I) - 5,
                Font1, 14)
        end if


    end for

    for D : 1 .. 4

        drawline (D * 200, maxy - 80, D * 200, maxy - 150, 0)
    end for

    Font.Draw ("Team " + natstr (Turn) + "'s turn", 300, maxy - 50, Font1, 7)
    drawline (200, maxy - 80, 800, maxy - 80, 0)
    Font.Draw ("PLOTS", 220, maxy - 120, Font1, 12)
    Font.Draw ("AUTHORS", 400, maxy - 120, Font1, 12)
    Font.Draw ("CHARACTERS", 625, maxy - 120, Font2, 12)
    Font.Draw ("TEAM 1", 1, 600, Font1, 14)
    Font.Draw ("TEAM 2", maxx - 200, 600, Font1, 14)
    Font.Draw ("$" + intstr (Score1), 1, 500, Font1, 0)
    Font.Draw ("$" + intstr (Score2), maxx - 200, 500, Font1, 0)

    View.Update
    exit when QuestionCount >= NUM_OF_QS

end loop
cls

if Score1 > Score2 then
Font.Draw ("TEAM 1 has won!", maxx div 2 , maxy div 2 , Font1, 10)
else
Font.Draw ("TEAM 2 has won!", maxx div 2 , maxy div 2 , Font1, 10)

end if

Sponsor
Sponsor
Sponsor
sponsor
TripleBla




PostPosted: Mon Oct 01, 2007 12:16 pm   Post subject: RE:A jepordy triva game

You didn't declare two variables.


Frigging god.
petree08




PostPosted: Wed Oct 03, 2007 8:19 am   Post subject: Re: A jepordy triva game

er yeah sorry here's the working version
and i forgot to mention before, when a player gets a right answer press the 1 key .
if the player is wrong press anyother key
if you wish to remove a question from the board after it is wrong press r
Nadine




PostPosted: Wed May 28, 2008 10:05 am   Post subject: RE:A jepordy triva game

why dont u just fix it so people wont get confused ? Razz Smile
petree08




PostPosted: Wed May 28, 2008 11:37 am   Post subject: RE:A jepordy triva game

dude, i wrote this in like 10 minutes for some stupid english presentation,

this program has terrible code and is not worth fixing, i just kinda hacked it together
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: