just define a tick rates, for example you want 100 logic steps(ticks) per second.so just save the time you started your simulation(game) and everytime you come around check the time and see howmany ticks you should have done until know and how many you already did, the delta of both values is the amount of new ticks to calculate.

lmfao ra4king.Everything i say you come along with a 'Don't do that..'.I code how I code, it gets things done how i want it to be done, if I did notice something that 'absolutely shouldn't be done' was done, I'd fix it.8/10 T.T

Yes, the random object is how you would go about doing random things. Like the above poster said.

And ra4king is right in that you should not create a new object every time you want to do a randomized thing so I would have maybe a static random object in your class or a class that just has a random object in it that you can call for random numbers.

@ GabrielBailey74 I think ra4king just wants to make sure people don't make mistakes so they won't repeat those mistakes later on. Yes it is good to have something working before you make sure it works well but don't be hard on him for helping.

Don't create a new Random object each time, instead store it in a global variable or use Math.random().

Don't use Math.random() it's synzronized so it a bit slower.(about 2-3 times)

Math.random() is not synchronized.

Creating a new Random object each time the method is called is not "bad practice", it will lead to undesired side effects, such as the same number being produced more than once if that method is called multiple times in the same millisecond

"Don't create a new Random object each time".If you look at the code it was for random x,y coordinates, obviously every time its ran through that method it's going to need a new 'Random()' to assign RANDOM variables to it right?..

There is actually nothing random about the Random class. It works using a seed, which by default is System.currentTimeMillis(). The next<xxx>() methods then do a bunch of complicated math and bit shifts, assign an updated seed, then returns a seemingly random number.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org