views:

1162

answers:

6

Hi there,

So, I'm going to develop my 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.

A: 

A good start would be:

Qt Tutorial

Perhaps if you need to cheat you may want to look here xpacman.tar.gz

stacker
I love to do things by myself, but I had a quick look at it. And I believe that I'm on the right track! Thank you.
Pym
+6  A: 

I think that QGraphicsViewframework 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.

Tadeusz A. Kadłubowski
Thanks. I'll try your solution :)
Pym
+1  A: 

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.

Nikola Kotur
I think I would not have time to order the book nor read it, I have to return the complete project this Friday ;)
Pym
It seems to me that you have an assignment like this https://engineering.purdue.edu/OOSD/F2008/assignment/assignment4.html. In that case, check out http://kpacman.sourceforge.net for hints.
Nikola Kotur
+1  A: 

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.

envalid
*"to embed widows"* sounds a bit harsh ;)
Georg Fritzsche
True that sounds funky. Widgets works better there.
envalid
Meh, QPainter is so nineties. One should definitely use QGraphicsView. I am working on a big set of Qt-based games, and porting to QGraphicsView makes the code considerably easier (and even faster, because it schedules the re-rendering automatically). - If you still need OpenGL to make it run fast, you just do view->setViewport(new QGLWidget); and be done.
Stefan Majewsky
A: 

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: http://gitorious.org/gluon/

leinir
This answer is of course less relevant to you, since you've got a very short time to do your work in, but it may well be relevant to others with a similar, less time restricted question ;)
leinir
Thanks anyway, I have bookmarked it for later!
Pym
+1  A: 

I'm developing a simulation of rigid bodies with Qt and OpenGL using the PhysX API from Nvidia. If you want to see this approach, look at my project at github: http://github.com/lucassimao/Simulacao-Estereologica

Lucas