Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do you randomize pictures?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Wintermini




PostPosted: Sat Jan 09, 2010 3:36 pm   Post subject: How do you randomize pictures?

Initially I wanted to randomize strings... but I don't think it's possible. This is actually for a multiple question, but I can do the button wait procedure or something so I'll let the user click on the answer.
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Sat Jan 09, 2010 4:11 pm   Post subject: Re: How do you randomize pictures?

You do randomized pictures the same way you do randomized strings.

first, store all the possibilities in an array:
Turing:


var myPics : array 1 .. 10 of int

myPics(1) := Pic.FileNew("mypic.jpg")
...
myPics(10) := Pic.FileNew("myPic10.jpg")


Then generate a random number to decide what picture to display:

Turing:

var tmp : int := Rand.Int(1,10)
Pic.Draw(myPics(tmp),x,y,picMode)


The same can be done with strings by changing the array into a string and replacing Pic.Draw with put.
Wintermini




PostPosted: Sat Jan 09, 2010 4:20 pm   Post subject: RE:How do you randomize pictures?

OMG THANK YOU!!!
saranya




PostPosted: Thu Jan 14, 2010 9:20 pm   Post subject: RE:How do you randomize pictures?

can u help me with making my pictures not repeat
Carey




PostPosted: Thu Jan 14, 2010 10:35 pm   Post subject: RE:How do you randomize pictures?

You would have to store all previous numbers in an array, then when you pick a number, check the array to make sure it hasn't been picked before. Alternatively, you could take your array of pictures and do a bunch of random swapping to mix the order up, then use a for loop to display them from 1 to 10
TheGuardian001




PostPosted: Thu Jan 14, 2010 10:38 pm   Post subject: Re: RE:How do you randomize pictures?

saranya @ Thu Jan 14, 2010 9:20 pm wrote:
can u help me with making my pictures not repeat


No, because I have no idea what you mean by that. Care to elaborate?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: