Ive create a game and the portion of the program I am having a problem is modeled with a slightly modified MVC model.
For the controller I use a TimerTask to run 60 times a second.
Controller(){
timer = new Timer();//
timer.schedule(tt,1000,1000/60);
}
TimerTask tt = new TimerTask() {//Controller member variable
public void run() {
timerUpdate();
}
};
timerUpdate(){
model.advanceGameLogic(); //Tells the model to increment a tick
if(model.isPlay()){
checkRowCount();//Logic to check if any rows have been removed
view.repaint(); //Tells model to repaint itself
updateNextShape(); //Tells class to poll model for new shape
}
}
All this seems fine to me but later inside model, from the advance gameLogic code, I try and update an array comprising the gameState.
Using logging before and after calls of colorArr[row][col] = s.getColor();
I am able to observe that multiple values in this array are being changed from this one call at once.
Have I used timers in an incorrect way so as to make the game logic inconsistent or are there other conditions that can result in my problem? I can update the code or post more about what calls are made to get to the array change if that will help.