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

Username:   Password: 
 RegisterRegister   
 help with going back to main menu
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jppk




PostPosted: Fri Jun 03, 2005 9:44 am   Post subject: help with going back to main menu

i have to make trivia game for ISP..
and i have used procedure to create 3 buttons in main menu
and within in each procedure there is like 20 questions and i would like to know how to finish the procedure and go back to main menu after the user has complete the 20 quesitons
Here is my program without any questions
code:

import GUI
var winID : int
winID := Window.Open ("position:0;0,graphics:800;600")

setscreen ("graphics:800:600")
var pic : int := Pic.FileNew ("back1.jpg")

Pic.Draw (pic, 0, 0, picMerge)
var font1, font2, font3 : int
font1 := Font.New ("Comicsans:20:bold,italic")
Font.Draw ("Welcome To", 300, 520, font1, white)
font3 := Font.New ("Arial:12:italic")
Font.Draw ("Please select your choice", 250, 380, font3, black)
font2 := Font.New ("Arial:18:bold")
Font.Draw ("E", 240, 500, font2, black)
delay (100)
Font.Draw ("N", 262, 495, font2, 20)
delay (100) %22
Font.Draw ("T", 284, 490, font2, 21)
delay (100)
Font.Draw ("E", 306, 485, font2, 22)
delay (100)
Font.Draw ("R", 328, 480, font2, 23)
delay (100)
Font.Draw ("T", 350, 475, font2, 24)
delay (100)
Font.Draw ("A", 372, 470, font2, 25)
delay (100)
Font.Draw ("I", 394, 465, font2, 26)
delay (100)
Font.Draw ("N", 410, 460, font2, 27)
delay (100)
Font.Draw ("M", 432, 455, font2, 28)
delay (100)
Font.Draw ("E", 460, 450, font2, 29)
delay (100)
Font.Draw ("N", 482, 445, font2, 30)
delay (100)
Font.Draw ("T", 504, 440, font2, 31)
delay (100)
Font.Draw ("T", 394, 430, font2, 20)
delay (100)
Font.Draw ("R", 416, 425, font2, 23)
delay (100)
Font.Draw ("I", 438, 420, font2, 26)
delay (100)
Font.Draw ("V", 450, 415, font2, 29)
delay (100)
Font.Draw ("I", 472, 410, font2, 30)
delay (100)
Font.Draw ("A", 490, 405, font2, 31)
procedure a
    cls
    var pic : int := Pic.FileNew ("movieback.jpg")
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("Movie Trivia", 50, 500, font1, white)
    delay (4000)
    cls
%questions
end a

procedure b
%exit the program
    cls
    colourback (black)
    cls
    for counter : 1 .. 1
        locate (20, 30)
        var word1 : string := "Thank you for using the program" %from compsci
        var cola1 : int := 35
        for row1 : 1 .. 25
            for counter1 : 1 .. 20
                put " " ..
            end for
        end for
        color (white)
        for a1 : 1 .. length (word1)
            locate (17, cola1)
            cola1 += 1
            put word1 (a1)
            delay (100)
        end for
    end for
    delay (1000)
    Window.Close (winID)
end b

procedure c
    cls
    var pic : int := Pic.FileNew ("musicback.jpg")
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("M", 60, 305, font1, black)
    Font.Draw ("u", 70, 285, font1, black)
    Font.Draw ("s", 80, 265, font1, black)
    Font.Draw ("i", 90, 245, font1, black)
    Font.Draw ("c", 100, 225, font1, black)
    Font.Draw ("T", 110, 200, font1, black)
    Font.Draw ("r", 120, 180, font1, black)
    Font.Draw ("i", 130, 160, font1, black)
    Font.Draw ("v", 140, 140, font1, black)
    Font.Draw ("i", 150, 120, font1, black)
    Font.Draw ("a", 160, 100, font1, black)
    delay (4000)
    cls
%questions
end c

procedure d
    var pic : int := Pic.FileNew ("tvback.jpg")
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("Television/Who says this?", 200, 305, font1, white)
    delay (4000)
    cls
%quesitons
end d



var button1 : int := GUI.CreateButton (250, 300, 300, "Movie", a)
var button2 : int := GUI.CreateButton (250, 200, 300, "Exit", b)
var button3 : int := GUI.CreateButton (250, 260, 300, "Music", c)
var button4 : int := GUI.CreateButton (250, 340, 300, "Television/Who says this?", d)


loop
    exit when GUI.ProcessEvent
end loop

Sponsor
Sponsor
Sponsor
sponsor
StarGateSG-1




PostPosted: Fri Jun 03, 2005 9:49 am   Post subject: (No subject)

Call the main procedure at the bottom of the question porcedure. Make sure you use forward procedure and body procedure though.
jppk




PostPosted: Fri Jun 03, 2005 10:21 am   Post subject: (No subject)

thank you for your reply but i dont really get what you said...sorry :oops:
can you give me example of the code plz thanks again
StarGateSG-1




PostPosted: Fri Jun 03, 2005 11:34 am   Post subject: (No subject)

An code example would be.

code:
forward procedure Main
forward procedure Quiz1
forward procedure Quiz2
forward procedure Quiz3

body procedure Main
Code
end Main

body procedure Quiz1
Quiz
Main
end Quiz1

body procedure Quiz2
Quiz
Main
end Quiz2

body procedure Quiz3
Quiz
Main
end Quiz3
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: