I’m designing Snakes and Ladders game. I’m using a timer to loop through the images of the dice and also for the ladders, snakes classes.
I’m having trouble when I’m using Thread.sleep() to have some latency between the pc turn and the player turn. The problem is that there’s a lag in the middle of any process for the timer e.g when the player button is placed on any square that has a ladder, the button is taking time till it’s getting to the top of the ladder. And same with the snakes and the dice.
I’ve looked up in Google a lot but I couldn’t find any solution. Any help will be really helpful.
Get a timestamp at the start and the end of the work to determine how long the work took to perform and then subtract that from your sleep time.
Alternatively use a
Timerif you want something to execute at a fixed interval.