How do these java sand games track so many particles?

Can anyone shed light on how such a structure can be structured?

What java classes will be used to track so many particles and then check for collisions? Particles must know which particles are nearby, or that they are not near anything, so they can fall, etc.

Here is an example if you do not know what a sand game is.

+5
source share
2 answers

Arrays, basically.

  • A one-dimensional array of actively moving grains represented by two coordinates (and possible speed, if you want gravitational acceleration).
  • bools ( ), .

- , (, , ): . . , . .

( , !)

+4

( ). 2D- (, ints ..), . :

  • ( [x] [y + 1]) , 1 (= [x] [y] , [x] [y + 1] )
  • , [x-1] [y + 1] , .
  • , [x + 1] [y + 1] , .

. , , "" ( , ).

, , , .

0

All Articles