Computer Science Canada using randint, Help asap, isp due tomoro!! |
Author: | johnbobbit [ Sat Jan 17, 2004 8:08 pm ] |
Post subject: | using randint, Help asap, isp due tomoro!! |
I am doing an isp which requires the usage of arrays, which i dont understand well. i have to make 5 different sized blocks each a different color appear on the screen in random order. I am able to make one square come out and each time it changes size and colour. now i need to get all of it's 5 forms to come out in random order. Thats the part i am stuck on and i've tried everything for about 6 hours now. if any body can help plz correct and guide me. here is the userInput part of my program code: var num : array 1 .. 5 of int var coord : array 1 .. 5 of int randomize var box : array 1 .. 5 of int := init (60, 80, 100, 120, 140) var boxEndx : array 1 .. 5 of int := init (0, 0, 0, 0, 0) var boxEndy : array 1 .. 5 of int := init (60, 80, 100, 120, 140) var c : int := 0 var x : int := 0 var f : string (1) procedure userInput randomize for y : 1 .. 5 randomize x := x + 1 randint (num (x), 1, 5) put (num (x)) exit when x > 5 randint (num (x), 1, 5) if num (x) = 1 then c := 7 elsif num (x) = 2 then c := 9 elsif num (x) = 3 then c := 12 elsif num (x) = 4 then c := 14 else c := 5 end if end for for a : 1 .. 5 for s : 1 .. 5 for y : 1 .. 5 x := x + 1 drawfillbox (100, 100, box (num (y)) + boxEndy (num (y)), box (num (y)) + box (num (y)), c) end for end for end for end userInput |
Author: | DanShadow [ Sat Jan 17, 2004 9:49 pm ] | ||||
Post subject: | |||||
k...first of all, you dont need to post the same post twice, just leave one, and wait for it to be answered. Secondly, dont name posts like "I NEED HELP ON THIS F*CKEN BITCH!!" of whatever it was. (This post title is good though.) With seeing two p osts with the same thing, I decided not to read your post, and just explain arrays to you, fair enough.
Thats how an array works...if you need more information, ask specifically, and nicely. ![]() This can be manipulated like so:
|
Author: | johnbobbit [ Sun Jan 18, 2004 3:19 pm ] |
Post subject: | It is still the same |
I need to randomize in the order which each block comes out |
Author: | recneps [ Sun Jan 18, 2004 4:20 pm ] |
Post subject: | |
so have a randint make a random number, and have it call up the boxsize of that nuber in the array, like randint(rand,1,5) and whatever it gives, tell it to call up that siz box.. drawbox(x(rand),y(rand),(x(rand)+50),(y(rand)+50),7) thatd make a box that is at the position that you randomized, and make it 50 by 50 pixels. understand? |
Author: | johnbobbit [ Sun Jan 18, 2004 4:46 pm ] |
Post subject: | Thanks for the reply |
Yes i understand that and i have wrote the new userInput procedure. The problem is that i need the 5 boxes which are differently sized, to come out in different order each time. so onece the largest may come first or second, or third or fourth or last. This goes for all the boxes. Heres the userInput procedre: %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 drawfillbox (space (i) + x (i), 200, space (i) + x (i) + x (i), y (i) + 200, i) end for end userInput userInput |