I wanted to rewrite my simple game engine to work on Android, and I wonder how I can synchronize two working streams. Now I have the following:
- Runner is the main action, the entry point to this game;
- CanvasView is just a canvas on which to draw;
- GameWorld - as the name implies - a class that stores current information about the state of the game. For now, let's just say that it also contains a level.
- GameLoop is a separate thread that updates the state of the game;
- CanvasThread is a separate thread that runs to draw the current level of CanvasView.
Since a layer is just a simple array, CanvasThread just iterates through the array and draws it on the screen. And I have few questions regarding this:
What is the best way to do this? I am a complete Java / Android newbie, so my way of tuning the engine is most likely not the best / best. If you have any design suggestions, I would be happy to appreciate them.
Thanks.
PS: If I violated all the best practices when creating the diagram above, please forgive me.
source share