Search code examples
androidmultithreadingopengl-es

Do I need multithreading for my game?


I'm trying to make a simple breakout game with opengl es, on Android, and I can't decide wether I have to use a seperate thread for certain game logic stuff, like updating the game and collission detection. I've prototyped a simple one: Drawing and Updating parallel of eachother in their own thread. It brought more problems than I thought, and so I thought:

Do I need more than one thread?

Since a breakout game for example, has like 6X5 grid of blocks, and for each block it needs to test
Does the ball touch this brick? And about 30 times a second. If I put this code in my main Drawing loop: OnDrawFrame(GL10) I'm afraid it will cost alot of rendering time.
So can I just return to single threaded game, or not? (since Android devices are not that powerful compared to ..pc's.


Solution

  • I'm trying to make a simple breakout game

    No, you do not need to thread anything.

    Threading is not for "simple" tasks. Threading is for tasks where you can reasonably expect significant problems with performance, such that you would actually gain something by going multithreaded.

    What you will gain by threading a Breakout clone is a coding headache. Nothing more. It simply isn't significant enough to require it, and if you don't need threading, you should almost never use it.