Computer Science Canada Help Needed Related to Randomizing Pictures |
Author: | glitchy_gal12 [ Sun May 28, 2006 3:07 pm ] |
Post subject: | Help Needed Related to Randomizing Pictures |
Ok, I have to create this slot machine program, from which I have to randomize 4 different shapes into 3 seperate square boxes on the same screen, and that the program's purpose is for the user to keep pushing a button until all three slot boxes have 3 identical shapes. The shapes that I am using are a star, an oval, a square, and a maple leaf. The program I'm using is Turing. I'm kind of struggling with this randomizing stuff. If you can, please help me with producing the code ![]() |
Author: | Cervantes [ Sun May 28, 2006 3:28 pm ] | ||
Post subject: | |||
You've got 4 possible shapes to produce on screen one. You can pick a random number between 1 and 4 using
|
Author: | glitchy_gal12 [ Sun May 28, 2006 3:37 pm ] | ||
Post subject: | |||
Cervantes wrote: You've got 4 possible shapes to produce on screen one. You can pick a random number between 1 and 4 using
Thanks for replying ![]() |
Author: | Cervantes [ Sun May 28, 2006 3:58 pm ] | ||
Post subject: | |||
Maybe. As for drawing your actual picture, the easiest thing to do would be to create an array of procedures.
Not sure I've got the syntax right, here. Can't test it at the moment. Try playing around with it if it's not right, then post back here with the syntax error. |
Author: | HellblazerX [ Sun May 28, 2006 4:09 pm ] |
Post subject: | |
Cervantes wrote: an array of procedures.
What?!!!! ![]() |
Author: | Cervantes [ Sun May 28, 2006 4:17 pm ] |
Post subject: | |
Yes, it extends to other languages. It extends especially well to functional languages (a procedure is just a function to a language that doesn't have a defined unit (nil) value, to paraphrase wtd). For an in-depth explanation of this phenomenon, see Turing as a Functional Programming Lanugage. |
Author: | glitchy_gal12 [ Sun May 28, 2006 4:29 pm ] | ||||
Post subject: | |||||
Cervantes wrote: Maybe.
As for drawing your actual picture, the easiest thing to do would be to create an array of procedures.
Not sure I've got the syntax right, here. Can't test it at the moment. Try playing around with it if it's not right, then post back here with the syntax error. Ok, I found no syntax errors (Horray!). ![]() ![]()
|
Author: | Cervantes [ Sun May 28, 2006 4:33 pm ] | ||
Post subject: | |||
|
Author: | glitchy_gal12 [ Sun May 28, 2006 4:42 pm ] | ||
Post subject: | |||
Cervantes wrote:
Would that code cause the shapes to overlap each other? I tried testing it onto Turing, and the shapes ended up overlapping. Is it possible for the three seperate outcomes to be in spaced out positions so that the different outcomes can be viewed more easily? By the way, thanks a million for helping me. ![]() |
Author: | Cervantes [ Sun May 28, 2006 5:02 pm ] | ||
Post subject: | |||
They're overlapping because you hardcoded the values into the box, star, oval, and mapleleaf procedures. Use the parameters. Cervantes wrote:
|
Author: | glitchy_gal12 [ Sun May 28, 2006 5:12 pm ] | ||
Post subject: | |||
Cervantes wrote: They're overlapping because you hardcoded the values into the box, star, oval, and mapleleaf procedures. Use the parameters.
Cervantes wrote:
Oh ok. I get it now. Once again. thanks so much for your time! ![]() |
Author: | Cervantes [ Sun May 28, 2006 6:16 pm ] |
Post subject: | |
glitchy_gal12 wrote: Once again. thanks so much for your time!
![]() It was my pleasure. ![]() |