bzar
A Commando
I know what you mean. I code loads of small prototypes and proof-of-concepts and game mechanic tests, but actually making a "finished" game is so much more work, and then you have to do all the boring stuff tooTalking about this stuff motivates me to actually try to finish something for once.
I don't mean to optimize early or over-engineer. I mean that we should try to compare different approaches, so we can avoid the same pitfalls. There's more than one way to do stuff, and more often than not the selected method has a flaw that makes you rewrite big portions of the game to fix. I'm a pretty hands-on kind of guy, an experimentalist if you will, though I can also appreciate a good architecture and well thought out abstractions. I just don't want to waste time on bad solutions that have hidden pitfalls.I seriously recommend not bothering with all those questions. Just write a couple of QTified classes, gather some artwork. When you actually hit a performance wall, we can all have some fun trying to fix it or annoy some nokia people to write us a better framework
If you would take a look at the original Quake3 sources from ID, you wouldn't believe what crap C++ design style they used. You can actually see what they bolted on the engine last minute. There's maybe 3 functions that are true genius. And still it's one of the top games ever.
I spend allot of time *wasted* on exercises in over-engineering, just to give up and start over.
Take a look at the giant list of non working abandoned linux games. Beautiful code, but no game.
I don't see an obvious good solution to updating the game world. QTimer gives no guarantees whatsoever on update frequency, which is why I've usually used a QTime to get a delta time to use with updates. QTimer silently discards timeout events, if the system can't keep up with them (link). This gives way to jerky updates, possible tunneling and undeterministic updates.
Probably the "Qt-est" way of doing the updates would be to have the objects update themselves using the "advance" method. The "advance" methods of QGraphicsItems are called when the parent QGraphicsScene's "advance" method is invoked (link). However, the "advance" method does not give any idea on how long has passed to the QGraphicsItems, so the items need a way to keep track of time themselves. The two obvious solution would be to use a QTime per item to keep track of time, but then you're even worse off than with a single QTime in the QGraphicsScene, because now you get not only different update times per frame, but different update times per item.
One way is to use QTimeLines for each game item to control the animations. This gives nice bonuses like ease curves for animations and alike. However, QTimeLines are much better suited to GUI animations than game world updates. They give no actual benefits over a QTimer/QTime and don't provide a time delta.
A separate game loop gives good stable updates. You can still use time deltas and do all you can to get constant intervals between updates. I have not, however, seen a good "Qt" implementation of a game main loop. As it has been pointed out, you still have to run the Qt main loop.
The above is mostly rambling and I usually use the QTimer+QTime route in my projects, but it's not nearly optimal (in terms of end result, performance aside). I just want to raise some conversation to get opinions and learn new, maybe better, ways to do the common stuff. Game world updating is just one thing. Collisions, particle management (QLinkedList has a mutating iterator that lets you delete items from a QLinkedList while iterating over it, very handy for particles), network multiplayer (I recently coded a quick test on real-time networked multiplayer using Qt) and alike have different approaches with different pros and cons and different levels of "Qt-ness". We all make our solutions as we go along, but it might be beneficial to share those solutions to find the best ones for common problems, so everyone won't have to invent the wheel again by goind from a triangle to square to pentagon to circle.
They're not that rare, are they? It's a very promising platform for games. I would guess there are games for Qt4 released by other instances as well?If you have released a QT4 based game, you are either a KDE programmer or a Nokia Employee, probably both.
Us mere mortals are just wetting our feet.
PS: This post is very much flow-of-thought. I just wanted to get some of my reasoning out in the open. Apologies for incoherent rambling.