Randomizing shapes
Author |
Message |
Space!!!
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Space!!!
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|
|