This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello All! I'm trying to implement a game which requires blocks falling from the top of the grid, and No it's not Tetris. I imagined it would be very simple using the built in JavaTimerTask, but after beginning to develop the game I'm having second thoughts. This is because at each *step* it goes through each player and moves their respective stub (blocks) down the grid until it hits the bottom, that is, the bottom of the grid or sits on top other previously fallen stubs (blocks). I would like to note that the graphics would be rigid in the sense that I am planning to have the grid represented as a 2D Matrix of JPanel/JComponent that are just color coded. So the movement of the stubs would be essentially setting the color of the previous set of blocks to white and then the next set of blocks to respective colors of the stub.
What I'm worried about is that when the stub hits the bottom of the grid, there will be some relatively heavy computation (NP complete) that could potentially decrease the throughput of the game. I am thinking about having a dispatch thread to perform the computation for the appropriate players who need the task performed.
I should also note, that the player will have the option of holding the down arrow to increase the speed of the stub to reaching the bottom.
Anyway, I think this game would be insanely fun. I'm definitely going to add a server/client model to it. Here are my questions, and I am open to suggestions
1. Is the Java TimerTask reliable for implementing a Fixed Frame Rate?
2. Should I use Fixed Frame Rate at all? or should I use Variable Frame Rate?
3. Would it ultimately be better to go the extra mile, and go from rigid motion to smoother motion?