Computer Science Canada

Hey i need help with Random stuff!

Author:  Jacx [ Sun Jan 23, 2005 1:59 am ]
Post subject:  Hey i need help with Random stuff!

I need to find a way to make a box appear in random places, (but you cannot move thru the box)

not i know it has to do with randint and the parimeters being variables, but the box comes out distorted every time!

Can someone please help me out?

whoever helpss gets TWELVE WHOPPEN BITS Razz

Author:  Bacchus [ Sun Jan 23, 2005 2:00 am ]
Post subject: 

well y dont you show us wat u have already and we'll try to help

Author:  Cervantes [ Sun Jan 23, 2005 8:57 am ]
Post subject: 

You're going to want to store a random location using two Rand.Ints: one for the x position of the box, one for the y. You'll also want to know the width and the height of the box. Draw the box using all that information. Then, collision detection.

Author:  Jacx [ Sun Jan 23, 2005 6:25 pm ]
Post subject: 

ok so i have this

code:
proc fini
var x: int
var y :int
randint (x, 200, 300)
randint  (y, 100, 200)
    drawfillbox (y, x, x, y, grey)
    drawfillbox (maxx - 30, 60, maxx - 60, 30, 0)
end fini



but it just keeps moving and the box wont stay in one position, plus im not sure how to make it move as a whole to other places.
Can anyone help??

Author:  Cervantes [ Sun Jan 23, 2005 6:53 pm ]
Post subject: 

It's probably not staying in one spot because you've probably got that procedure inside a loop.
To actually move the box, do what I said before.
Cervantes wrote:

You're going to want to store a random location using two Rand.Ints: one for the x position of the box, one for the y. You'll also want to know the width and the height of the box. Draw the box using all that information.

Why you are drawing the box at (y,x) (x, y) is beyond me.

Author:  Jacx [ Sun Jan 23, 2005 6:57 pm ]
Post subject: 

I thought thats the only way you can draw them, i dont know much about turing graphics

Author:  Jacx [ Mon Jan 24, 2005 6:37 pm ]
Post subject: 

Can anyone help me???

Author:  cycro1234 [ Mon Jan 24, 2005 6:41 pm ]
Post subject: 

So basically you want a shape of the same size to appear in random locations on the screen?

Author:  cycro1234 [ Mon Jan 24, 2005 6:41 pm ]
Post subject: 

So basically you want a shape of the same size to appear in random locations on the screen?

Author:  cycro1234 [ Mon Jan 24, 2005 6:41 pm ]
Post subject: 

So basically you want a shape of the same size to appear in random locations on the screen?

Author:  Jacx [ Mon Jan 24, 2005 6:44 pm ]
Post subject: 

yes exactly!

Author:  cycro1234 [ Mon Jan 24, 2005 6:44 pm ]
Post subject: 

So basically you want a shape of the same size to appear in random locations on the screen?

Author:  Bacchus [ Mon Jan 24, 2005 6:46 pm ]
Post subject: 

rofl 4 of the same posts Razz

Author:  Jacx [ Mon Jan 24, 2005 6:49 pm ]
Post subject: 

Lolwtf

Ahhh this project is due tommorow and i have NO idea how to make the box's appear and STAY in there, if anyone can help me, i can send you the program and you can see whats wrong with it, i just cant fix it, ive been trying for hours!

Author:  Bacchus [ Mon Jan 24, 2005 7:01 pm ]
Post subject: 

code:
var x,y,clr:int
for i:1..100 %how many boxes you want
    randint(x,0,maxx-30)
    randint(y,0,maxy-30)
    randint(clr,0,maxcolor)
    drawfillbox(x,y,x+30,y+30,clr)
end for

Author:  Jacx [ Mon Jan 24, 2005 7:09 pm ]
Post subject: 

wow thats great but theres a problem

The boxeskeep jumping to every possible location, theres no way for me to just make the boxs STAY where they are suppsto be, there like stuck in a loop, when there not in a loop!

Author:  cycro1234 [ Mon Jan 24, 2005 7:20 pm ]
Post subject: 

Sorry for the multiple posts Embarassed Computer got messed

Author:  cycro1234 [ Mon Jan 24, 2005 7:26 pm ]
Post subject: 

What do u mean they jump??

Author:  Jacx [ Mon Jan 24, 2005 7:51 pm ]
Post subject: 

like they go to random places, but they dont STOP going to random places, and the box / boxs keep flashing in every possible position on the screen

Author:  Cervantes [ Mon Jan 24, 2005 9:11 pm ]
Post subject: 

Jacx wrote:

when there not in a loop!

They are...
If you want to stop making the boxes jump around the screeneliminate the loop... Rolling Eyes

Author:  Jacx [ Mon Jan 24, 2005 9:21 pm ]
Post subject: 

yes buit when i take them out of the loop, they dissapear very fast

Author:  Bacchus [ Mon Jan 24, 2005 9:27 pm ]
Post subject: 

then your probably clear the screen. i guess you want a random box that wont be cleared right?
code:
%put out of loop
var x:int:=Rand.Int(0,maxx-30)
var y:int:=Rand.Int(0,maxy-30)
var clr:int:=Rand.Int(0,maxcolor)
%in loop
drawfillbox(x,y,x+30,y+30,clr)


: