There is a 2D game with a top view in the real-time RPG genre. The game is written in Java using the Swing library. It is planned to rewrite the part responsible for drawing using JOGL, as well as further transfer the game to Android.
Therefore, I tried to separate the logic from the presentation in such a way that in one place there was pure logic that knows nothing about that someone is going to draw it and in another place there was a display code that received the state of the model through getters and model data is drawn and how to do it. I managed to comply with this principle until it became necessary to animate images.
What was required of the animation: during the gameplay, I should have had the opportunity to pause the animation, resume it, change the playback speed, select an animation for an object depending on the state of its model, play not all the animation but only a part.
Where the problem occurred:
1.) It turned out that each object should store the current frame number, the number of frames for a given state, and the speed of animation playback for a given state. The frame number and playback speed are individual for each object. Therefore, the model began to store data related to the display.
2.) In some moments, the logic became dependent on animation, since Some actions can be performed only after the corresponding animation is played.
3.) Animation for each type of object is stored as a single image, which when you start the game is read and programmatically sliced. To perform the cutting, you need to know the size of the frame, which states of the object are animated, the number of frames for each such state, in what sequence in the image these states are depicted. Mapping is involved in this task, but some of the data it needs has become to store the model, while the model object storing this information may not yet be created.
Question: where is it better to store the data necessary for playing the animation and preparing the images? How to preserve the independence of the model from the display, taking into account the above mentioned difficulties?
Please tell me which architectural solution is best suited in this case.