Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

util.Random problems (?)  RSS feed

Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Im fooling around with a small particle engine for J2ME, and
for each particle (in the particle flock) I need to generate
a beginning x and y value, and an "update/speed vector" (xi,yi) with the
help of Random.

Emperical tests shows, that the particles tend to flock together.
I suspect, that util.Random "reuses" the generated values..

does anyone have any info on the above?

In general about the engine:

loop thru' the flock of particles:
if particle p is active -> p.update
else reset p

x= x + xi
y= y + yi

sets the x,y,xi and yi values with random.nextInt() % 3

/Svend Rost
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!