Game development with Qt: where to look first?

Viewed 25031

So, I'm going to develop a Pac-Man clone with Qt. The problem is that I do not really know where to start.

I quickly take a look at the documentation and some demo. I also downloaded some game sources on qt-apps.org. And it seems that there is a lot of ways to develop a game with Qt!

In your experience, which part of Qt should I consider to develop a Pac-Mac clone ?

  • The Animation Framework
  • The Graphics View Framework
  • The Paint System
  • Qt Declarative

Any help would be appreciated.

8 Answers

I think that QGraphicsView framework is the best way. Create a QGraphicsScene, some QGraphicsItems for the elements of the game. You have collision detection for free.

Most of KDE games are based on the QGraphicsView framework. It is a good fit for simple game development.

At the very minimum you will want to look at QGLWidget. You can get an OpenGL program up in a few minutes by deriving from QGLWidget, it will create the window, context, handle mouse and keyboard input, etc. Create a QTimer to trigger updateGL() every 10-15 ms or so and your good to go. I think there is a demo somewhere for setting this up, but it has been awhile since I saw it.

If you want to embed widgets into the window, I would look at QGraphicsView. There is a demo of this called boxes. Just beware the demo is a tad hard to learn from as several classes are thrown into the same file and it might take a few moments of tracing to figure out where the flow is.

Since you are doing a 2d game, you might want to look at using QPainter on top of OpenGL. This allows you to draw primitives easily instead of doing them with OpenGL calls. I never could get this to stop flickering in fullscreen though.

There's a book about game development in Qt here, it's a bit old, but it might give you some ideas. But IMHO, Qt is widget based and is a bit slow for a game, you might consider using SDL or OpenGL.

Well, one place to look could be the Gluon game development framework, which is currently under development. It depends on what you're really aiming for with your PacMan clone, but Gluon may well be what you're after: https://github.com/KDE/gluon

Related