Randomizing 5 different blocks
Author |
Message |
johnbobbit
|
Posted: Sun Jan 18, 2004 10:04 am Post subject: Randomizing 5 different blocks |
|
|
thanks to some kind person who read my message i was able to get this far. I am trying to make my userInput procedure run
5 different sized boxes appear on the screen, each a different color according to size. The catch is that each time the program is run the order of the boxes has to change. I was unable to do this so can someone read my code and tell me how please.
thanks
%user input
procedure userInput
var x:array 1..5 of int:=init(60,80,100,120,140)
var y:array 1..5 of int:=init(60,80,100,120,140)
var space:array 1..5 of int:=init(-50,20,110,220,350)
for i:1..5
randomize
drawfillbox(space(i)+x(i),100,space(i)+x(i)+x(i),y(i)+100,i)
end for
end userInput
userInput |
|
|
|
|
|
Sponsor Sponsor
|
|
|
shorthair
|
Posted: Sun Jan 18, 2004 10:34 am Post subject: (No subject) |
|
|
Rename the topic title please ,you will get more help , we know you need help because you posted in the HELP forum , |
|
|
|
|
|
johnbobbit
|
Posted: Sun Jan 18, 2004 4:53 pm Post subject: ok, i changed it |
|
|
ok i changed it, can u help me on the program? |
|
|
|
|
|
Tony
|
|
|
|
|
johnbobbit
|
Posted: Sun Jan 18, 2004 6:33 pm Post subject: hello tony |
|
|
hello tony
i've tried the randint command and it doesnt make anything better.
What do u sugest i randomize or change
%user input
procedure userInput
var x:array 1..5 of int:=init(60,80,100,120,140)
var y:array 1..5 of int:=init(60,80,100,120,140)
var space:array 1..5 of int:=init(-50,20,110,220,350)
for i:1..5 randint(x(i),x(1),x(5))
drawfillbox(space(i)+x(i),200,space(i)+x(i)+x(i),y(i)+200,i)
end for
end userInput
userInput
thanks |
|
|
|
|
|
McKenzie
|
Posted: Sun Jan 18, 2004 10:01 pm Post subject: (No subject) |
|
|
It's still hard to tell exactly what you need to do. The best I can understand by your description; the size and location of your boxes are the same each time but you want the order to change. Please clarify. (why have a -50 size ?)
Must each of the 5 appear exactly once? Or is it the case that you want 5 randomly sized and located boxes (by what criteria does size translate to colour?) |
|
|
|
|
|
johnbobbit
|
Posted: Sun Jan 18, 2004 10:09 pm Post subject: Hi macKenzie |
|
|
for this program i need the size of the boxes to stay the same but for their x location to change everytime the program is run, in the order that it is right now it goes smallest to largest(1,2,3,4,5) but i need it to run different each time like( 2,3,4,1,5) for example. Also each time it is run i need the color to stay with the specific sized sqaure, for example the small square is always blue.
thanks |
|
|
|
|
|
Boarder16
|
Posted: Sun Jan 18, 2004 10:40 pm Post subject: (No subject) |
|
|
if you wanted to go really simple (in my opinion0 you could do seperate procedures.. heres an EXAMPLE
var box, boxx, boxy, boxc :int
proc box1
drawfillbox(boxx,boxy,boxx+20(width of box),boxy+20(height of box),boxc(color of box)
end box1
proc box2
drawfillbox(boxx,boxy,boxx+10(width of box),boxy+10(height of box),boxc(color of box)
end box2
proc box3
drawfillbox(boxx,boxy,boxx+25(width of box),boxy+25(height of box),boxc(color of box)
end box3
proc box4
drawfillbox(boxx,boxy,boxx+43(width of box),boxy+43(height of box),boxc(color of box)
end box4
proc box5
drawfillbox(boxx,boxy,boxx+30(width of box),boxy+30(height of box),boxc(color of box)
end box5
proc box6
drawfillbox(boxx,boxy,boxx+40(width of box),boxy+40(height of box),boxc(color of box)
end box6
loop
randint(boxx, 1, (maximum - however wide the box will be)(in other words how wide)
randint(boxy, 1, (maximum - however tall teh box will be)(in other word how tall)
randint(box, 1,6)
if box = 1 then box1
elsif box = 2 then box2
elsif box = 3 then box3
elsif box = 4 then box4
elsif box = 5 then box5
elsif box = 6 then box6
end if
%I'M NOT SURE HOW BUT YOU MUST FIND OUT HOW TO TAKE AWAY ONE VALUE FROM THE RANDINTS CHOICES, SO IT CANNOT CALL TEH SAME COLOR, OR BOX PROCEDURE TWICE... THIS IS A MORE SIMPLIER/EASIER WAY TO SEE OR UNDERSTAND IT..FOR ME ANYWAY BUT IT IS ALOT LENGTHIER THAN IT CAN BE DONE IN..I MEAN THIS IS VERY LONG LOL....BUT IF U DON'T CARE IT WILL BE FINE
end loop
MIND YOU THIS IS NOT THE COMPLETE CODE TO DO THIS..SOME TINKERING WILL HAVE TO BE DONE.. CASUE I JSUT TYPED IT NOW.. BUT IT IS A BASIC STRUCTURE FOR SOMETHIN LIKE THAT... OK |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|