Help with sorting game
Author |
Message |
Jundu
|
Posted: 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 code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
pkjr92
|
Posted: Mon Jan 12, 2009 6:59 pm Post subject: Re: Help with sorting game |
|
|
Turing: |
put "Use [CODE] tags..."
|
|
|
|
|
|
|
|
|