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

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




PostPosted: Mon Jan 12, 2009 6:53 pm   Post subject: Help with sorting game

Can someone help me make it so that these blocks can only appear on userInput and can someone also help me make it so that you can sort them from smallest to biggest please i'm such a turing noob and i honestly need this help

Turing:
import GUI
View.Set ("offscreenonly")
var piecesX : array 1 .. 3 of int %
var piecesY : array 1 .. 3 of int
var piecesWidth : array 1 .. 3 of int 
var mainWinID := Window.Open ("graphics:700;500")
var font1 : int
font1 := Font.New ("Arial:12:bold")
procedure title
    cls
    Font.Draw ("Sort the Blocks!", 200, 470, font1, red)
    GUI.Refresh
end title
proc setup
    for i : 1 .. 3
        piecesX (i) := i * 120
        piecesY (i) := 105
        piecesWidth (i) := Rand.Int (30, 100)
    end for

   

end setup
proc userInput
    var mouseX, mouseY, button : int
    mousewhere (mouseX, mouseY, button)

    if button = 1 then
        for i : 1 .. 3
           
            if mouseX > piecesX (i) and mouseX < piecesX (i) + piecesWidth (i) and mouseY > piecesY (i) and mouseY < piecesY (i) + piecesWidth (i) then
               
                if mouseX - piecesWidth (i) div 2 > 100 and mouseX + piecesWidth (i) div 2 < 540 and mouseY - piecesWidth (i) div 2 > 100 and mouseY + piecesWidth (i) div 2 < 350 then
                    piecesX (i) := mouseX - piecesWidth (i) div 2
                    piecesY (i) := mouseY - piecesWidth (i) div 2
                    exit
                end if
            end if
        end for
    end if


    drawfillbox (101, 101, 539, 349, white)
    for i : 1 .. 3
        drawfillbox (piecesX (i), piecesY (i), piecesX (i) + piecesWidth (i), piecesY (i) + piecesWidth (i), blue)
    end for
    View.Update
end userInput
procedure mainMenu
    title
    locate (6, 30)
    put "This is the main menu select an option!"
    var playButton : int := GUI.CreateButton (100, 10, 10, "Play!", userInput)

end mainMenu
procedure introduction
    title
    locate (3, 20)
    put "See if you can sort the blocks from smallest to largest!"
    var menuButton : int := GUI.CreateButton (10, 10, 10, "Main Menu", mainMenu)
end introduction
proc goodBye
    cls
    locate (maxrow div 2, maxcol div 2 - 6)
    put "Created By: Zakaria"
end goodBye
introduction
setup
loop
    userInput
exit when GUI.ProcessEvent ()
end loop
goodBye




Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
pkjr92




PostPosted: Mon Jan 12, 2009 6:59 pm   Post subject: Re: Help with sorting game

Turing:

put "Use [CODE] tags..."
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  [ 2 Posts ]
Jump to:   


Style:  
Search: