Slick and Timers?

Posted by user3491043 on Game Development See other posts from Game Development or by user3491043
Published on 2014-05-26T19:42:13Z Indexed on 2014/05/26 22:06 UTC
Read the original article Hit count: 446

Filed under:
|
|
|
|

I'm making a game where I need events to happen in a precise amount of time. Explanation : I want that event A happens at 12000ms, and event B happens every 10000ms.

So "if"s should looks like this.

//event A
if(Ticks == 12000) //do things
//even B
if(Ticks % 10000 == 0) //do stuff

But now how can I have this "Ticks" value ? I tried to declare an int and then increasing it in the update method, I tried 2 ways of increasing it :

Ticks++;

It doesn't works because the update method is not always called every microseconds.

Ticks += delta;

It's kinda good but the delta is not always equals to 1, so I can miss the precise values I need in the if statements

So if you know how can I do events in a precise amount of time please tell me how can I do this

© Game Development or respective owner

Related posts about java

Related posts about slick