if (do_name() != 'Home') : ?>
endif ?>
Posted by anonymous on Feb 06, 2008
Set it into a variable, as follows:
x = random() # Set x to a random number print x oval(10, 10, x, x) # x is always the same valueHope this helps!
Posted by Augusto on Feb 07, 2008
Yes, but I am making a loop with a random within it, that will generate a random
Position of an object, eg
X1 = random (50)
Y1 = random (50)
X2 = next value generated by random
Y2 = next value generated by random
oval (x, y, 10,10)
line (x1, y1, x2, y2)
Actually I do not need the previous value, but the next value generated at random ()
Understand + -?
sorry about my english...
Posted by fdb on Feb 07, 2008
- I create the random point first, and append it to trails directly, so I can access trails[0].
- I start drawing the trails from the second element(trails[1]), because I already stored the first position in x0, y0.
- The last line leaves only the last 10 trails.
If there are any more questions with this, I'll be happy to answer them.
include("util/comment.php"); ?>
There are a few ways to do this. One of the easiest is to remember the previous numbers in global variables, and use these, e.g.
speed(10) def setup(): global prevx, prevy prevx, prevy = random(50), random(50) def draw(): global prevx, prevy x, y = random(50), random(50) oval(x-5, y-5, 10, 10) line(prevx, prevy, x, y, stroke=0) prevx, prevy = x, yNow, if what you want to implement are trails, then you're better of using a list of previous coordinates. Here's an example:
size(200, 200) speed(10) def setup(): global trails trails = [] def draw(): global trails x, y = random(200), random(200) trails.append((x, y)) x0, y0 = trails[0] for x1, y1 in trails[1:]: line(x0, y0, x1, y1, stroke=0) x0, y0 = x1, y1 oval(x-5, y-5, 10, 10) trails = trails[-10:]There are a few things to note here:
- I create the random point first, and append it to trails directly, so I can access trails[0].
- I start drawing the trails from the second element(trails[1]), because I already stored the first position in x0, y0.
- The last line leaves only the last 10 trails.
If there are any more questions with this, I'll be happy to answer them.
how to use the previous number generated by
Posted by Augusto Carmo on Feb 06, 2008how to use the previous number generated by
random()?