
-----------------------------------
Jacx
Sun Jan 23, 2005 1:59 am

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 :P

-----------------------------------
Bacchus
Sun Jan 23, 2005 2:00 am


-----------------------------------
well y dont you show us wat u have already and we'll try to help

-----------------------------------
Cervantes
Sun Jan 23, 2005 8:57 am


-----------------------------------
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.

-----------------------------------
Jacx
Sun Jan 23, 2005 6:25 pm


-----------------------------------
ok so i have this

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??

-----------------------------------
Cervantes
Sun Jan 23, 2005 6:53 pm


-----------------------------------
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.

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.

-----------------------------------
Jacx
Sun Jan 23, 2005 6:57 pm


-----------------------------------
I thought thats the only way you can draw them, i dont know much about turing graphics

-----------------------------------
Jacx
Mon Jan 24, 2005 6:37 pm


-----------------------------------
Can anyone help me???

-----------------------------------
cycro1234
Mon Jan 24, 2005 6:41 pm


-----------------------------------
So basically you want a shape of the same size to appear in random locations on the screen?

-----------------------------------
cycro1234
Mon Jan 24, 2005 6:41 pm


-----------------------------------
So basically you want a shape of the same size to appear in random locations on the screen?

-----------------------------------
cycro1234
Mon Jan 24, 2005 6:41 pm


-----------------------------------
So basically you want a shape of the same size to appear in random locations on the screen?

-----------------------------------
Jacx
Mon Jan 24, 2005 6:44 pm


-----------------------------------
yes exactly!

-----------------------------------
cycro1234
Mon Jan 24, 2005 6:44 pm


-----------------------------------
So basically you want a shape of the same size to appear in random locations on the screen?

-----------------------------------
Bacchus
Mon Jan 24, 2005 6:46 pm


-----------------------------------
rofl 4 of the same posts :P

-----------------------------------
Jacx
Mon Jan 24, 2005 6:49 pm


-----------------------------------
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!

-----------------------------------
Bacchus
Mon Jan 24, 2005 7:01 pm


-----------------------------------
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

-----------------------------------
Jacx
Mon Jan 24, 2005 7:09 pm


-----------------------------------
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!

-----------------------------------
cycro1234
Mon Jan 24, 2005 7:20 pm


-----------------------------------
Sorry for the multiple posts  :oops:  Computer got messed

-----------------------------------
cycro1234
Mon Jan 24, 2005 7:26 pm


-----------------------------------
What do u mean they jump??

-----------------------------------
Jacx
Mon Jan 24, 2005 7:51 pm


-----------------------------------
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

-----------------------------------
Cervantes
Mon Jan 24, 2005 9:11 pm


-----------------------------------

when there not in a loop!

They are...
If you want to stop making the boxes jump around the screeneliminate the loop... :roll:

-----------------------------------
Jacx
Mon Jan 24, 2005 9:21 pm


-----------------------------------
yes buit when i take them out of the loop, they dissapear very fast

-----------------------------------
Bacchus
Mon Jan 24, 2005 9:27 pm


-----------------------------------
then your probably clear the screen. i guess you want a random box that wont be cleared right?
%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)
