Using threads in a near completed game
BlitzMax Forums/BlitzMax Programming/Using threads in a near completed game
| ||
I there a way to use threads to just make my main classes run smoothly Ive noticed that it sometimes jerks through windows doing stuff. Im just learnt java and learning android and xml they use threads. so the game is smooth. this is my main game programs loop all the other classes have been created and initialised and I only have 4 to update in the main loop. is there a way to create threads for these? Repeat Cls GKeys.Update() Main_Control.Update() Main_Control.Draw() Sound_Pro.Update() Flip Until Quit_Program = True Or AppTerminate() prob have to look into threads with blitzmax so sorry if its a stupid question Cheers Dibble |
| ||
2 things to keep in mind. Not all things can be put on a child thread (like drawing), and making things thread safe can be quite a lot of work depending on your structures. It's not impossible to convert an existing project, but it's generally FAR easier if you've planned for it from the start. |
| ||
Have you looked at your object creation and garbage collection in your main loop? You may not need threads to smooth things out. |
| ||
Also, do your updates *outside* of the drawing loop. By using "Flip", you're locking your render to 60 fps, so your logic is also locked at that. By updating outside the Cls...Flip block, you're not limited to that, so you can update your game as fast as possible. |
| ||
ok cheers. I will have to do some reading on blitzmax and threads. possibly rewriting the program from the start after I have released it. also do some garbage collection as I assumed that when a object was deleted from a list it was automatically freed from memory. shoddy programming on my part. also I was been lazy and not reading the forums, I just thought they would be an easy fix. thanks again Dibble |
| ||
It look like OOP Blitz Max Programming isn't it? |
| ||
The short answer is no. The longer answer is that it depends. If a lot of your hickups are caused by deleting object then that can be shoved off to a thread with minor complication. Object creation is much more of a hassle, and regular processing almost always requires a complete rethinking of the code. |