I am trying to create a game in java using several design patterns / principles. One of them being MVC. The situation is like this: Model: Holds all game logic Controller: Button interaction and list of GameElements (see code) View: All GUI stuff including drawing.
Now, my game objects are all located under the Model, but for my drawing I've tried doing this (inside paintComponent)
ArrayList<GameElement> ge = FieldController.getElements(); // This is located under Controller
for(GameElement ge: GameElements)
{
graphics.setColor(ge.getColor());
graphics.fillRect(ge.x,ge.y,ge.width,ge.height);
}
Which works, but my question is: Where should the ArrayList of GameElements really be kept? Is it okay to hold it in the control? Or should it be kept in the view? I'm quite sure it should not be held in the model because then View&Model would be too tightly coupeled.