Computer Science Canada

Random display

Author:  PhOeNiX-47 [ 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

Author:  Paul [ Fri May 21, 2004 7:15 pm ]
Post subject: 

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

Author:  PhOeNiX-47 [ Mon May 24, 2004 6:40 pm ]
Post subject: 

How do I use array to display a pic?

Author:  guruguru [ Mon May 24, 2004 7:07 pm ]
Post 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.

Author:  PhOeNiX-47 [ Mon May 24, 2004 7:18 pm ]
Post subject: 

OMG~!!! That works! U are the GURU!

Author:  PhOeNiX-47 [ Mon May 24, 2004 7:22 pm ]
Post 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.

Author:  SuperGenius [ Mon May 24, 2004 7:43 pm ]
Post 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

Author:  guruguru [ Mon May 24, 2004 7:47 pm ]
Post 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 !

Author:  PhOeNiX-47 [ Mon May 24, 2004 8:19 pm ]
Post subject: 

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

Author:  guruguru [ Mon May 24, 2004 8:38 pm ]
Post 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.


: