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

Username:   Password: 
 RegisterRegister   
 Randomizing shapes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Space!!!




PostPosted: Tue Jan 11, 2011 11:36 pm   Post subject: Randomizing shapes

What is it you are trying to achieve?
I need to have 5 blocks in random order displayed, with 5 empty spaces below.
Then the user selects it and puts it in the correct location.

What is the problem you are having?
i dont know how to have 5 blocks in random order. The same six blocks not changing its shape every time.

Describe what you have tried to solve this problem
i used randint, but if i use that it will display different squares every time. I need it to show a set of 5 blocks randomize its order every time!

%My code till now
import GUI
var r : int
procedure RandBlocks
randint (r, 0, 35)
drawfillbox (100 + r, 300, 150, 350, red)
drawfillbox (200 - r, 300, 250, 350 + r, blue)
drawfillbox (300, 300, 350, 350 + r,green)
drawfillbox (400 - r, 300, 450, 350, yellow)
drawfillbox (500 - r, 300, 550 + r, 350 + r, purple)
%Blank Boxes
drawbox (100, 200, 150, 250, brightred)
drawbox (200, 200, 250, 250, brightred)
drawbox (300, 200, 350, 250, brightred)
drawbox (400, 200, 450, 250, brightred)
drawbox (500, 200, 550, 250, brightred)
GUI.Refresh
end RandBlocks

View.Set ("graphics:1000;600")
var draw : int := GUI.CreateButtonFull (50, 10, 0, "Draw Blocks",
RandBlocks, 0, '^D', true)
var quitBtn : int := GUI.CreateButton (200, 10, 0, "Exit", GUI.Quit)
loop
exit when GUI.ProcessEvent
end loop

Turing version : 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jan 11, 2011 11:40 pm   Post subject: Re: Randomizing shapes

Space!!! @ Tue Jan 11, 2011 11:36 pm wrote:
if i use that it will display different squares every time. I need it to show a set of 5 blocks randomize its order every time!

I can't say that I understand that.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Space!!!




PostPosted: Wed Jan 12, 2011 8:43 am   Post subject: RE:Randomizing shapes

If u run my code hen u will notice that the blocks keep changing their shape right? So there are 5 blocks(different sizes) I need them to be in random oder every time i hit run.Without changing its shape.
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: