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

Username:   Password: 
 RegisterRegister   
 Hey i need help with Random stuff!
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jacx




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Bacchus




PostPosted: Sun Jan 23, 2005 2:00 am   Post subject: (No subject)

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




PostPosted: Sun Jan 23, 2005 8:57 am   Post subject: (No 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.
Jacx




PostPosted: Sun Jan 23, 2005 6:25 pm   Post subject: (No 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??
Cervantes




PostPosted: Sun Jan 23, 2005 6:53 pm   Post subject: (No 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.
Jacx




PostPosted: Sun Jan 23, 2005 6:57 pm   Post subject: (No subject)

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




PostPosted: Mon Jan 24, 2005 6:37 pm   Post subject: (No subject)

Can anyone help me???
cycro1234




PostPosted: Mon Jan 24, 2005 6:41 pm   Post subject: (No subject)

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




PostPosted: Mon Jan 24, 2005 6:41 pm   Post subject: (No subject)

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




PostPosted: Mon Jan 24, 2005 6:41 pm   Post subject: (No subject)

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




PostPosted: Mon Jan 24, 2005 6:44 pm   Post subject: (No subject)

yes exactly!
cycro1234




PostPosted: Mon Jan 24, 2005 6:44 pm   Post subject: (No subject)

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




PostPosted: Mon Jan 24, 2005 6:46 pm   Post subject: (No subject)

rofl 4 of the same posts Razz
Jacx




PostPosted: Mon Jan 24, 2005 6:49 pm   Post subject: (No 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!
Bacchus




PostPosted: Mon Jan 24, 2005 7:01 pm   Post subject: (No 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
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 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: