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

Username:   Password: 
 RegisterRegister   
 need help asap please
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nin




PostPosted: Sun Jan 14, 2007 7:07 pm   Post subject: need help asap please

i made a next button so when the user enters the answer of their choice it will move on to the next question and so on and so on. Also i was wondring how do you keep track of the person's score and show it to the person at the end of the game?

code:
%Set screen up
import GUI
setscreen ("graphics")

%Declaration Section
var mainWin := Window.Open ("graphic: 640;200")
var key : string (1)
var number, randomNum : int
var try : int := 3
var mainMenuBtn, playBtn, nextBtn, quitBtn : int := 0

%Title
proc title
    locate (1, 36)
    put "Math Game"
end title

%Introduction
proc introduction
    GUI.Refresh
    title
    locate (3, 1)
    put "This program will be testing your math skills."
    GUI.Show (mainMenuBtn)
    GUI.Hide (nextBtn)
    GUI.Hide (playBtn)
    GUI.Hide (quitBtn)
end introduction

%Main Menu
proc mainMenu
    cls
    GUI.Hide (mainMenuBtn)
    GUI.Hide (nextBtn)
    GUI.Show (playBtn)
    GUI.Show (quitBtn)
    title
    locate (3, 1)
    put "To proceed, please press any of the below buttons."
    GUI.Refresh
end mainMenu

%Random Number
proc randNum
    randint (randomNum, 10, 65)
end randNum

%User input's error message
proc errorMessage
    var windID1 := Window.Open ("position:300;300,graphics: 330;100")
    locate (1, 1)
    put "Please enter 1, 2, 3 or 4."
    locate (5, 1)
    put "To proceed, please press any key" ..
    loop
        exit when hasch
    end loop
    Window.Close (windID1)
end errorMessage

%Display
proc display
    GUI.Show (mainMenuBtn)
    title
    try := -1
    randNum
    if number = randomNum then
        locate (3, 1)
        put "Good Job!"
        put "Tries remaining: ", try

    elsif number < randomNum then
        put "Too low!"
        put "Tries remaining:", try

    else
        put "Your guess is too high!"
        put "Tries remaining:", try
    end if

    if try = 0 then
        locate (6, 1)
        put "The random number chosen was: ", randomNum
    end if
end display


%User Input
proc userInput
    cls
    title
    locate (3, 1)
    put "How do you calculate the volume of a prism? " ..
    locate (5, 1)
    put "1.V = Area of base x height"
    put "2.V = 1/3 x area of base x height"
    put "3.V = Base x 1/3 x base x height"
    put "4.V = Base x Height"
    put "Answer: " ..
    get number
    GUI.Show (nextBtn)
    GUI.Hide (mainMenuBtn)

    if number < 1 or number > 5 then
        errorMessage
        userInput

    else
    end if
    display
end userInput


%Good Bye
proc goodBye
    var windID2 := Window.Open ("graphics:640;400")
    Window.Close (mainWin)
    locate (12, 29)
    put "This program was written by:"
    locate (13, 35)
    put "******** *******"
    locate (14, 39)
    put "Goodbye!"
    delay (2500)
    Window.Close (windID2)
end goodBye

%Buttons
mainMenuBtn := GUI.CreateButtonFull (270, 160, 0, "Main Menu", mainMenu, 0, '^M', false)
playBtn := GUI.CreateButtonFull (282, 220, 0, "Start Game", userInput, 0, '^P', false)
nextBtn := GUI.CreateButtonFull (400, 100, 0, "Next", userInput, 0, '^N', false)
quitBtn := GUI.CreateButton (300, 100, 0, "Exit", GUI.Quit)

%Main Program
introduction
loop
    exit when GUI.ProcessEvent
end loop
goodBye

%End of program


Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Sun Jan 14, 2007 7:12 pm   Post subject: RE:need help asap please

Keeping track of someones score is one of the most advanced concepts in programming. Many people fail to grasp this concept and few use it effectively. Some people say it is as simple as using a variable but it is commonly argued among scholars that this was rendered useless 50 years ago.
nin




PostPosted: Sun Jan 14, 2007 7:56 pm   Post subject: Re: need help asap please

o yeah i forgot i am just fixing the codes. i used my other codes to make my game and then im changing it up to turn it into a new game. the display ignore it for now n the other things that does not relate to the math game process.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: