Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Multithreading in qt
Hi, I am creating a side scrolling game for symbian device and part of my game is to have an enemy for my character to attack to.
Do I have to use multithreading in creating the enemy? Thanks for your replies!
That's a pretty vague question. I'd guess you probably don't need to.
What would be your reasoning for considering multithreading?
I am going to create an enemy in my game and I would to know if multithreading is an option since the enemy needs to attack or defend, right? I am correct?
lgeyer last edited by
From the limitied amount of information you provided there is a clear no from me.
Keep in mind that any GUI related operation has to be done in the main thread anyways. So if your enemy isn't doing any resource-intensive stuff which would block the main thread for an unreasonable amount of time the overhead will outweigh the benefits.
[quote author="theCrazyCrap" date="1328675533"]I am going to create an enemy in my game and I would to know if multithreading is an option since the enemy needs to attack or defend, right? I am correct?
To be honest I'm not quite sure what this should have to do with multithreading.
I am thinking of using the multithread because the enemy in the game is moving. Just like in any side scrolling game. the enemy would attack the player once the player is in the area. correct?
In making this event, do i need to do this on the main thread?
andre last edited by
No, you really do not need multithreading for this. It will only get you into more problems than you already have. Judging from the way you pose your questions, you are a beginner at programming. There is nothing wrong with that - we all started that way - but it is wise to start at the basics. Multi threading definately is not the 'basics' kind of technology.
I am just new in QT.. I don't know where to start in developing our game. Do you have any suggestions in creating a side scrolling game? If we don't need multithreadin, how are we going to create the enemy while the character is moving.
andre last edited by
The key is to use event-based programming. That means that instead of having the program fully dedicate itself to just one aspect (your enemy sprite, for instance), you quickly react to incomming events (timers, key presses, mouse input). That gives you the opportunity to update both your emenies and your playing character without using threading. Note that there are no complicated things you have to do to use this technique in Qt. Qt is event based from the base up. The only trick is to make sure that you don't do blocking operations, so no endless loops for animations for instance.
Thank you so much for your help! Now I get it... I'll just post here if I have more question.. Thank you again for your help!