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

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




PostPosted: Sun Jan 27, 2008 10:24 pm   Post subject: Need help with game

I am done programming my game but i dont know why the interface doesnt work and the checking part in my game to check for the order, here is my program:

import GUI
%need to finish sorting the names in alphabetical order
setscreen ("graphics:300;200,nobuttonbar")

put " Alphabetical Game By:Hammad Raja"

var xpos, ypos, btn : int

var frame : int := GUI.CreateFrame (200, 70, 100, 170, GUI.LINE)

var x : flexible array 1 .. 1 of string

%get names
var fstream : int
open : fstream, "wordlist3.txt", get
loop
exit when eof (fstream)
get : fstream, x (upper (x))
new x, upper (x) + 1
end loop
% The "Music.PlayFile" program.
process DoMusic
loop
Music.PlayFile ("The_Ballad_of_Black_Mesa_l.mp3")
end loop
end DoMusic

fork DoMusic

var word : array 1 .. 5 of string
var exiT : int := 0

word (1) := x (Rand.Int (1, 26))
word (2) := x (Rand.Int (1, 26))
word (3) := x (Rand.Int (1, 26))
word (4) := x (Rand.Int (1, 26))
word (5) := x (Rand.Int (1, 26))

loop
for one : 1 .. 5
for two : 1 .. 5
if word (one) = word (two) then
word (1) := x (Rand.Int (1, 26))
word (2) := x (Rand.Int (1, 26))
word (3) := x (Rand.Int (1, 26))
word (4) := x (Rand.Int (1, 26))
word (5) := x (Rand.Int (1, 26))
else
exiT := 1
end if
end for
end for
exit when exiT = 1
end loop
var word2 : array 1 .. 5 of string
for k : 1 .. 5
word2 (k) := word (k)
end for


var word1x : int := 3
var word2x : int := 3
var word3x : int := 3
var word4x : int := 3
var word5x : int := 3


var wordy : array 1 .. 5 of int
wordy (1) := 150
wordy (2) := 130
wordy (3) := 110
wordy (4) := 90
wordy (5) := 70
%junk
procedure aa
end aa
procedure bb
end bb
procedure dd
end dd
procedure ff
end ff
procedure gg
end gg
%/junk
var button : array 1 .. 5 of int
button (1) := GUI.CreateButton (word1x, wordy (1), 10, word (1), aa)
button (2) := GUI.CreateButton (word2x, wordy (2), 10, word (2), bb)
button (3) := GUI.CreateButton (word3x, wordy (3), 10, word (3), dd)
button (4) := GUI.CreateButton (word4x, wordy (4), 10, word (4), ff)
button (5) := GUI.CreateButton (word5x, wordy (5), 10, word (5), gg)

var width1 : int := GUI.GetWidth (button (1))
var width2 : int := GUI.GetWidth (button (2))
var width3 : int := GUI.GetWidth (button (3))
var width4 : int := GUI.GetWidth (button (4))
var width5 : int := GUI.GetWidth (button (5))

var height1 : int := GUI.GetHeight (button (1))
var height2 : int := GUI.GetHeight (button (2))
var height3 : int := GUI.GetHeight (button (3))
var height4 : int := GUI.GetHeight (button (4))
var height5 : int := GUI.GetHeight (button (5))

%sort
var counter : int := 1
var temp : string
for alpha : 97 .. 122
for win : 1 .. 5
if ord (word (win) (1)) = alpha then


temp := word (counter)
word (counter) := word (win)
word (win) := temp
counter := counter + 1
end if
end for
end for


var Skip : array 1 .. 5 of int
for SKIP : 1 .. 5
Skip (SKIP) := SKIP
end for

procedure checkwin
%win word(correct), word2(original), button,wordy(height)
for check : 1 .. 5


for check2 : 1 .. 5
if word (check) = word2 (check2) then

for checky : 1 .. 5

if check = 1 then
if wordy (check2) >= wordy (checky) then
Skip (1) := check2

else
exit
end if
end if
if check = 2 and checky not= Skip (1) then
if wordy (check2) >= wordy (checky) then
Skip (2) := check2

else
exit
end if
end if

if check = 3 and checky not= Skip (1) and checky not= Skip (2) then
if wordy (check2) >= wordy (checky) then
Skip (3) := check2

else
exit
end if
end if
if check = 4 and checky not= Skip (1) and checky not= Skip (2) and checky not= Skip (3) then
if wordy (check2) >= wordy (checky) then
Skip (4) := check2

else
exit
end if
end if
if check = 5 and checky not= Skip (1) and checky not= Skip (2) and checky not= Skip (3) and checky not= Skip (4) then
if wordy (check2) >= wordy (checky) then
%light up??
cls
put "Good Job You Win!!"
var x, y, button : int
loop
mousewhere (x, y, button)
drawbox (10, 10, 110, 110, black)
locatexy (48, 65)
put "Exit"
exit when 10 <= x and x <= 110 and 10 <= y and y <= 110 and button = 1
end loop
parallelput (1)

else
cls
put "You Lose,Try Again"
var x, y, button : int
loop
mousewhere (x, y, button)
drawbox (10, 10, 110, 110, black)
locatexy (48, 65)
put "Exit"
exit when 10 <= x and x <= 110 and 10 <= y and y <= 110 and button = 1
end loop
parallelput (2)
exit
end if

end if



end for
end if

end for
end for

end checkwin
procedure endwin
quit
end endwin
var quitbutton : int := GUI.CreateButton (200, 80, 0, "exit", endwin)
var checkbutton : int := GUI.CreateButton (200, 100, 0, "check", checkwin)
%drag and drop
loop
mousewhere (xpos, ypos, btn)


if btn = 1 and xpos >= word1x - 10 and xpos <= word1x + width1 and ypos >= wordy (1) - 10 and ypos <= wordy (1) + height1 then
loop
mousewhere (xpos, ypos, btn)
word1x := xpos
wordy (1) := ypos
GUI.SetPosition (button (1), word1x, wordy (1))
GUI.SetPosition (button (2), word2x, wordy (2))
GUI.SetPosition (button (3), word3x, wordy (3))
GUI.SetPosition (button (4), word4x, wordy (4))
GUI.SetPosition (button (5), word5x, wordy (5))
GUI.SetPosition (frame, 100, 70)
exit when btn = 0
end loop
end if

if btn = 1 and xpos >= word2x - 10 and xpos <= word2x + width2 and ypos >= wordy (2) - 10 and ypos <= wordy (2) + height2 then
loop
mousewhere (xpos, ypos, btn)
word2x := xpos
wordy (2) := ypos
GUI.SetPosition (button (1), word1x, wordy (1))
GUI.SetPosition (button (2), word2x, wordy (2))
GUI.SetPosition (button (3), word3x, wordy (3))
GUI.SetPosition (button (4), word4x, wordy (4))
GUI.SetPosition (button (5), word5x, wordy (5))
GUI.SetPosition (frame, 100, 70)

exit when btn = 0
end loop
end if

if btn = 1 and xpos >= word3x - 10 and xpos <= word3x + width3 and ypos >= wordy (3) - 10 and ypos <= wordy (3) + height3 then
loop
mousewhere (xpos, ypos, btn)
word3x := xpos
wordy (3) := ypos
GUI.SetPosition (button (1), word1x, wordy (1))
GUI.SetPosition (button (2), word2x, wordy (2))
GUI.SetPosition (button (3), word3x, wordy (3))
GUI.SetPosition (button (4), word4x, wordy (4))
GUI.SetPosition (button (5), word5x, wordy (5))
GUI.SetPosition (frame, 100, 70)
exit when btn = 0
end loop
end if

if btn = 1 and xpos >= word4x - 10 and xpos <= word4x + width4 and ypos >= wordy (4) - 10 and ypos <= wordy (4) + height4 then
loop
mousewhere (xpos, ypos, btn)

word4x := xpos
wordy (4) := ypos
GUI.SetPosition (button (1), word1x, wordy (1))
GUI.SetPosition (button (2), word2x, wordy (2))
GUI.SetPosition (button (3), word3x, wordy (3))
GUI.SetPosition (button (4), word4x, wordy (4))
GUI.SetPosition (button (5), word5x, wordy (5))
GUI.SetPosition (frame, 100, 70)
exit when btn = 0
end loop
end if

if btn = 1 and xpos >= word5x - 10 and xpos <= word5x + width5 and ypos >= wordy (5) - 10 and ypos <= wordy (5) + height5 then
loop
mousewhere (xpos, ypos, btn)
word5x := xpos
wordy (5) := ypos
GUI.SetPosition (button (1), word1x, wordy (1))
GUI.SetPosition (button (2), word2x, wordy (2))
GUI.SetPosition (button (3), word3x, wordy (3))
GUI.SetPosition (button (4), word4x, wordy (4))
GUI.SetPosition (button (5), word5x, wordy (5))
GUI.SetPosition (frame, 100, 70)
exit when btn = 0
end loop
end if


exit when GUI.ProcessEvent

end loop
Sponsor
Sponsor
Sponsor
sponsor
Mackie




PostPosted: Sun Jan 27, 2008 11:13 pm   Post subject: RE:Need help with game

Well, I can't debug it very easily if I can't run it! could you please package all the files that go along with the program.

Also when posting code, please use either:
code:

[code][/code]

or preferably
code:

[syntax="turing"][/syntax]

It will keep indentation and highlight keywords, makes it easier to read.
firex2249




PostPosted: Sun Jan 27, 2008 11:23 pm   Post subject: Re: Need help with game

Srry:

Turing:
import GUI
%need to finish sorting the names in alphabetical order
setscreen ("graphics:300;200,nobuttonbar")

put "   Alphabetical Game By:Uknown"

var xpos, ypos, btn : int

var frame : int := GUI.CreateFrame (200, 70, 100, 170, GUI.LINE)

var x : flexible array 1 .. 1 of string

%get names
var fstream : int
open : fstream, "wordlist3.txt", get
loop
    exit when eof (fstream)
    get : fstream, x (upper (x))
    new x, upper (x) + 1
end loop

var word : array 1 .. 5 of string
var exiT : int := 0

word (1) := x (Rand.Int (1, 26))
word (2) := x (Rand.Int (1, 26))
word (3) := x (Rand.Int (1, 26))
word (4) := x (Rand.Int (1, 26))
word (5) := x (Rand.Int (1, 26))

loop
    for one : 1 .. 5
        for two : 1 .. 5
            if word (one) = word (two) then
                word (1) := x (Rand.Int (1, 26))
                word (2) := x (Rand.Int (1, 26))
                word (3) := x (Rand.Int (1, 26))
                word (4) := x (Rand.Int (1, 26))
                word (5) := x (Rand.Int (1, 26))
            else
                exiT := 1
            end if
        end for
    end for
    exit when exiT = 1
end loop
var word2 : array 1 .. 5 of string
for k : 1 .. 5
    word2 (k) := word (k)
end for


var word1x : int := 3
var word2x : int := 3
var word3x : int := 3
var word4x : int := 3
var word5x : int := 3


var wordy : array 1 .. 5 of int
wordy (1) := 150
wordy (2) := 130
wordy (3) := 110
wordy (4) := 90
wordy (5) := 70
%junk
procedure aa
end aa
procedure bb
end bb
procedure dd
end dd
procedure ff
end ff
procedure gg
end gg
%/junk
var button : array 1 .. 5 of int
button (1) := GUI.CreateButton (word1x, wordy (1), 10, word (1), aa)
button (2) := GUI.CreateButton (word2x, wordy (2), 10, word (2), bb)
button (3) := GUI.CreateButton (word3x, wordy (3), 10, word (3), dd)
button (4) := GUI.CreateButton (word4x, wordy (4), 10, word (4), ff)
button (5) := GUI.CreateButton (word5x, wordy (5), 10, word (5), gg)

var width1 : int := GUI.GetWidth (button (1))
var width2 : int := GUI.GetWidth (button (2))
var width3 : int := GUI.GetWidth (button (3))
var width4 : int := GUI.GetWidth (button (4))
var width5 : int := GUI.GetWidth (button (5))

var height1 : int := GUI.GetHeight (button (1))
var height2 : int := GUI.GetHeight (button (2))
var height3 : int := GUI.GetHeight (button (3))
var height4 : int := GUI.GetHeight (button (4))
var height5 : int := GUI.GetHeight (button (5))

%sort
var counter : int := 1
var temp : string
for alpha : 97 .. 122
    for win : 1 .. 5
        if ord (word (win) (1)) = alpha then


            temp := word (counter)
            word (counter) := word (win)
            word (win) := temp
            counter := counter + 1
        end if
    end for
end for


var Skip : array 1 .. 5 of int
for SKIP : 1 .. 5
    Skip (SKIP) := SKIP
end for

procedure checkwin
    %win word(correct), word2(original), button,wordy(height)
    for check : 1 .. 5


        for check2 : 1 .. 5
            if word (check) = word2 (check2) then

                for checky : 1 .. 5

                    if check = 1 then
                        if wordy (check2) >= wordy (checky) then
                            Skip (1) := check2

                        else
                            exit
                        end if
                    end if
                    if check = 2 and checky not= Skip (1) then
                        if wordy (check2) >= wordy (checky) then
                            Skip (2) := check2

                        else
                            exit
                        end if
                    end if

                    if check = 3 and checky not= Skip (1) and checky not= Skip (2) then
                        if wordy (check2) >= wordy (checky) then
                            Skip (3) := check2

                        else
                            exit
                        end if
                    end if
                    if check = 4 and checky not= Skip (1) and checky not= Skip (2) and checky not= Skip (3) then
                        if wordy (check2) >= wordy (checky) then
                            Skip (4) := check2

                        else
                            exit
                        end if
                    end if
                    if check = 5 and checky not= Skip (1) and checky not= Skip (2) and checky not= Skip (3) and checky not= Skip (4) then
                        if wordy (check2) >= wordy (checky) then
                            %light up??
                            cls
                            put "Good Job You Win!!"
                            var x, y, button : int
                            loop
                                mousewhere (x, y, button)
                                drawbox (10, 10, 110, 110, black)
                                locatexy (48, 65)
                                put "Exit"
                                exit when 10 <= x and x <= 110 and 10 <= y and y <= 110 and button = 1
                            end loop
                            parallelput (1)

                        else
                            cls
                            put "You Lose,Try Again"
                            var x, y, button : int
                            loop
                                mousewhere (x, y, button)
                                drawbox (10, 10, 110, 110, black)
                                locatexy (48, 65)
                                put "Exit"
                                exit when 10 <= x and x <= 110 and 10 <= y and y <= 110 and button = 1
                            end loop
                            parallelput (2)
                            exit
                        end if

                    end if



                end for
            end if

        end for
    end for

end checkwin
procedure endwin
    quit
end endwin
var quitbutton : int := GUI.CreateButton (200, 80, 0, "exit", endwin)
var checkbutton : int := GUI.CreateButton (200, 100, 0, "check", checkwin)
%drag and drop
loop
    mousewhere (xpos, ypos, btn)


    if btn = 1 and xpos >= word1x - 10 and xpos <= word1x + width1 and ypos >= wordy (1) - 10 and ypos <= wordy (1) + height1 then
        loop
            mousewhere (xpos, ypos, btn)
            word1x := xpos
            wordy (1) := ypos
            GUI.SetPosition (button (1), word1x, wordy (1))
            GUI.SetPosition (button (2), word2x, wordy (2))
            GUI.SetPosition (button (3), word3x, wordy (3))
            GUI.SetPosition (button (4), word4x, wordy (4))
            GUI.SetPosition (button (5), word5x, wordy (5))
            GUI.SetPosition (frame, 100, 70)
            exit when btn = 0
        end loop
    end if

    if btn = 1 and xpos >= word2x - 10 and xpos <= word2x + width2 and ypos >= wordy (2) - 10 and ypos <= wordy (2) + height2 then
        loop
            mousewhere (xpos, ypos, btn)
            word2x := xpos
            wordy (2) := ypos
            GUI.SetPosition (button (1), word1x, wordy (1))
            GUI.SetPosition (button (2), word2x, wordy (2))
            GUI.SetPosition (button (3), word3x, wordy (3))
            GUI.SetPosition (button (4), word4x, wordy (4))
            GUI.SetPosition (button (5), word5x, wordy (5))
            GUI.SetPosition (frame, 100, 70)

            exit when btn = 0
        end loop
    end if

    if btn = 1 and xpos >= word3x - 10 and xpos <= word3x + width3 and ypos >= wordy (3) - 10 and ypos <= wordy (3) + height3 then
        loop
            mousewhere (xpos, ypos, btn)
            word3x := xpos
            wordy (3) := ypos
            GUI.SetPosition (button (1), word1x, wordy (1))
            GUI.SetPosition (button (2), word2x, wordy (2))
            GUI.SetPosition (button (3), word3x, wordy (3))
            GUI.SetPosition (button (4), word4x, wordy (4))
            GUI.SetPosition (button (5), word5x, wordy (5))
            GUI.SetPosition (frame, 100, 70)
            exit when btn = 0
        end loop
    end if

    if btn = 1 and xpos >= word4x - 10 and xpos <= word4x + width4 and ypos >= wordy (4) - 10 and ypos <= wordy (4) + height4 then
        loop
            mousewhere (xpos, ypos, btn)

            word4x := xpos
            wordy (4) := ypos
            GUI.SetPosition (button (1), word1x, wordy (1))
            GUI.SetPosition (button (2), word2x, wordy (2))
            GUI.SetPosition (button (3), word3x, wordy (3))
            GUI.SetPosition (button (4), word4x, wordy (4))
            GUI.SetPosition (button (5), word5x, wordy (5))
            GUI.SetPosition (frame, 100, 70)
            exit when btn = 0
        end loop
    end if

    if btn = 1 and xpos >= word5x - 10 and xpos <= word5x + width5 and ypos >= wordy (5) - 10 and ypos <= wordy (5) + height5 then
        loop
            mousewhere (xpos, ypos, btn)
            word5x := xpos
            wordy (5) := ypos
            GUI.SetPosition (button (1), word1x, wordy (1))
            GUI.SetPosition (button (2), word2x, wordy (2))
            GUI.SetPosition (button (3), word3x, wordy (3))
            GUI.SetPosition (button (4), word4x, wordy (4))
            GUI.SetPosition (button (5), word5x, wordy (5))
            GUI.SetPosition (frame, 100, 70)
            exit when btn = 0
        end loop
    end if


    exit when GUI.ProcessEvent

end loop




wordlist3.txt
 Description:
List of words

Download
 Filename:  wordlist3.txt
 Filesize:  137 Bytes
 Downloaded:  80 Time(s)

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: