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

Username:   Password: 
 RegisterRegister   
 Random display
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
PhOeNiX-47




PostPosted: Fri May 21, 2004 5:27 pm   Post subject: Random display

This might sound a little noobish but how do u display random pics at same time without stop the program using a 'for' count?

// Turing is really a baaaaaad program for making games... Sad
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Fri May 21, 2004 7:15 pm   Post subject: (No subject)

put pics in array, randomize the subscripts, then draw the pic.
PhOeNiX-47




PostPosted: Mon May 24, 2004 6:40 pm   Post subject: (No subject)

How do I use array to display a pic?
guruguru




PostPosted: Mon May 24, 2004 7:07 pm   Post subject: (No subject)

code:

var myPics : array 1 .. 2 of int
var picNumber : int

myPics(1) := ("pic1.bmp")
myPics(2) := ("pic2.bmp")

randint (picNumber, 1, 2)

Pic.Draw (myPics(picNumber), ..., ..., ...)


Ta dah.
PhOeNiX-47




PostPosted: Mon May 24, 2004 7:18 pm   Post subject: (No subject)

OMG~!!! That works! U are the GURU!
PhOeNiX-47




PostPosted: Mon May 24, 2004 7:22 pm   Post subject: (No subject)

Hm... but doesn that mean i have to use multiple pics for multiple spaceships? I want one pic to be able to multiply all overthe screen.
SuperGenius




PostPosted: Mon May 24, 2004 7:43 pm   Post subject: (No subject)

then you need to have the program draw your picture in a loop, with a couple randint statements in there for the x and y coords of the pic
guruguru




PostPosted: Mon May 24, 2004 7:47 pm   Post subject: (No subject)

I dont understand. Do you want a random picture to be displayed in a certain place, or a single picture displayed in random places, or a number of random pictures to be displayed in random places?

For the second option:
code:

const NUMBER_OF_INSTANCES := 5

var myPic := Pic.FileNew ("spaceship.bmp")
var posX, posY : array 1 .. NUMBER_OF_INSTANCES  of int

for i : 1 .. NUMBER_OF_INSTANCES 
    randint (posX(i), 0, maxx)
    randint (posY(i), 0, maxy)
    Pic.Draw (myPic, posX(i), posY(i), Pic.Merge
end for


Thats what I think you mean. If you want to incorporate a random picture from a collection of pictures than use my previous posts and when you draw the pics, use the random pic in the for loop.

EDIT: Ah! SuperGenius beat me Razz ! I just repeated what he said so know I look stupid Crying or Very sad Laughing !
Sponsor
Sponsor
Sponsor
sponsor
PhOeNiX-47




PostPosted: Mon May 24, 2004 8:19 pm   Post subject: (No subject)

Ya but that stops my original program Sad This is a big dilema
guruguru




PostPosted: Mon May 24, 2004 8:38 pm   Post subject: (No subject)

What is your main program exactly? Drawing the picutres is one of the main parts of any program. I don't know what your code or game is like so I can't help much more.... use View.Update and offscreenonly Confused ? Maybe post your're program... or you can PM the code so everybody doesnt copy your code.
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  [ 10 Posts ]
Jump to:   


Style:  
Search: