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

Username:   Password: 
 RegisterRegister   
 Help with turing storage
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jundu




PostPosted: Tue Jan 13, 2009 9:33 pm   Post subject: Help with turing storage

Can someone help me with how to make my done button in userInput work and how to make it so that turing can recognize if these boxes are in the GUI.Frame from smallest to biggest


code:

mport GUI
setscreen ("noecho")
setscreen ("offscreenonly")
var mainWinID := Window.Open ("graphics:700;500")
var font1 : int
font1 := Font.New ("Arial:12:bold")
var boxX : array 1 .. 5 of int
var boxY : array 1 .. 5 of int
var boxesWidth : array 1 .. 5 of int
var gameStart : boolean := false
var menuButton : int := 0
var playButton : int := 0
var frameX : array 1 .. 5 of int
var frameY : array 1 .. 5 of int
var frameWidth : array 1 .. 5 of int
var displayButton : int := 0
procedure title
    cls
    Font.Draw ("Sort the Blocks!", 200, 470, font1, red)
    GUI.Refresh
end title
procedure userInput
    title
    GUI.Hide (playButton)
    var mouseX, mouseY, button : int
    mousewhere (mouseX, mouseY, button)
    for i : 1 .. 5
        drawfillbox (boxX (i), boxY (i), boxX (i) + boxesWidth (i), boxY (i) + boxesWidth (i), white)
    end for
    for i : 1 .. 5
        if mouseX > boxX (i) and mouseX < boxX (i) + boxesWidth (i) and mouseY > boxY (i) and mouseY < boxY (i) + boxesWidth (i) then
            %if mouseX + boxesWidth (i) div 2 > 100 and mouseX + boxesWidth (i) div 2 < 540 and mouseY + boxesWidth (i) div 2 > 170 and mouseY + boxesWidth (i) div 2 < 40 then
            if button = 1 then
                boxX (i) := mouseX - boxesWidth (i) div 2
                boxY (i) := mouseY - boxesWidth (i) div 2
                exit
            end if
        end if
    end for
    for i : 1 .. 5
        drawfillbox (boxX (i), boxY (i), boxX (i) + boxesWidth (i), boxY (i) + boxesWidth (i), blue)
    end for
    for i : 1 .. 5
        frameX (i) := i * 100
        frameY (i) := 50
        frameWidth (i) := 100
        var randFrame := GUI.CreateFrame (frameX (i), frameY (i), frameX (i) + frameWidth (i), frameY (i) + frameWidth (i), GUI.EXDENT)
        var randFrame2 := GUI.CreateFrame (frameX (i) - 10, frameY (i) + 160, frameX (i) + frameWidth (i), frameY (i) + 160 + frameWidth (i), GUI.EXDENT)
        GUI.Show (displayButton)
    end for
    % drawfillbox (101, 101, 539, 349, white)
    % cls

    View.Update
    View.Set ("offscreenonly")
    GUI.Refresh
end userInput
proc startGame
    gameStart := true
    for i : 1 .. 5
        boxX (i) := i * 100
        boxY (i) := 210
        boxesWidth (i) := Rand.Int (15, 100)
    end for
end startGame
procedure mainMenu
    title
    locate (6, 30)
    put "This is the main menu select an option!"
    GUI.Show (playButton)
    GUI.Hide (menuButton)
end mainMenu
procedure goodBye
    cls
    locate (1, 30)
    put "Made By: Zakaria"
end goodBye
procedure introduction
    title
    locate (3, 20)
    put "See if you can sort the blocks from smallest to largest!"
    GUI.Hide (playButton)
    GUI.Hide (displayButton)
end introduction
procedure display
    title
    put "iutyryrth"
end display
menuButton := GUI.CreateButton (10, 10, 10, "Main Menu", mainMenu)
playButton := GUI.CreateButton (100, 10, 10, "Play!", startGame)
displayButton := GUI.CreateButton (400, 400, 20, "Done!", display)
introduction
loop
    if gameStart then
        userInput
    end if
    exit when GUI.ProcessEvent ()
end loop
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: