Author |
Message |
hydraweapon
|
Posted: Sat Jun 04, 2005 3:01 pm Post subject: Puzzle |
|
|
hey guys, i have a problem. i am supposed to make a puzzle where the person clicks on one box and then on another if both pictures are the same they stay open, otherwise they close. i already made the twelve boxes, but i dont know how to randomize the pictures so that they all would be in different spots so 6 pics and u have to put each pic twice
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Delos

|
Posted: Sat Jun 04, 2005 9:45 pm Post subject: (No subject) |
|
|
You would use arrays, and Rand.Int() commands. Probably also include some counters, so you know how many of each pic are allocated.
Check out the Tutorials for info on how to use all the above if you're not sure.
|
|
|
|
|
 |
hydraweapon
|
Posted: Sun Jun 05, 2005 10:09 am Post subject: (No subject) |
|
|
also i was wondering if there is a command in turing where you can goto certain line in a program, just like in c
|
|
|
|
|
 |
[Gandalf]

|
Posted: Sun Jun 05, 2005 11:09 am Post subject: (No subject) |
|
|
You shouldn't need goto command in Turing. They're completely not neccessary. Post what you would like to do and I am sure mostly anyone will tell you there is different - better - solution.
Could this be what uou want?
code: | var number : int
procedure goodnumber
put "Good job, ", number, " is in the specified range!"
end goodnumber
put "Enter a number 1-4"
get number
if number > 4 then
put "Too high"
else
goodnumber
end if |
The use of the procedure is completely pointless, but it's to show you. If theat's what you want then look up the tutorial on procedures.
|
|
|
|
|
 |
hydraweapon
|
Posted: Sun Jun 05, 2005 11:55 am Post subject: (No subject) |
|
|
no its just if my program is very long and i want it to jump from one line to another and it would be easier if i use gotos
|
|
|
|
|
 |
[Gandalf]

|
Posted: Sun Jun 05, 2005 12:00 pm Post subject: (No subject) |
|
|
Not sure what you mean... If you just want to skip a part of the code when something happens then use an if statement.
code: | if condition then
code
end if |
so if the conditions are not met then the code is executed.
If you really need goto then I am pretty sure there is a tutorial on "faking the goto line in Turing" or something like that.
|
|
|
|
|
 |
Bacchus

|
Posted: Sun Jun 05, 2005 6:22 pm Post subject: (No subject) |
|
|
If you need to 'goto' a line in Turing, either loop it around or make what you need more then once into a procedure. That way the procedure can be used as many time as you need, then you can add in parameters to make the procedure change for what is needed of it.
|
|
|
|
|
 |
1of42
|
Posted: Sun Jun 05, 2005 7:23 pm Post subject: Re: Puzzle |
|
|
hydraweapon wrote: hey guys, i have a problem. i am supposed to make a puzzle where the person clicks on one box and then on another if both pictures are the same they stay open, otherwise they close. i already made the twelve boxes, but i dont know how to randomize the pictures so that they all would be in different spots so 6 pics and u have to put each pic twice
I'm not sure how to do this in Turing, but I did something similar in Java, through the use of Vectors, pseudocode for the loading of the pictures goes something like this:
Put 2 of each picture in the vector.
Get a random int(index) from 0 to the length of the vector
Use the picture at that index, then remove it afterwards.
I'm not sure how to do this in Turing - I don't know of an analogous construct to a Vector.
By the way, goto statements = VERY BAD. If you're using them, you're doing something wrong.
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
hydraweapon
|
Posted: Sun Jun 05, 2005 8:06 pm Post subject: (No subject) |
|
|
alright thanx for your advice, this is wat i got so far:
Description: |
|
 Download |
Filename: |
New WinZip File.zip |
Filesize: |
49.23 KB |
Downloaded: |
158 Time(s) |
|
|
|
|
|
 |
|