views:

403

answers:

4
+1  Q: 

Qt4 2D Game Engine

Are there any 2-D Game Engines for Qt4 out there? I want a game engine that has collision detection, and runs smoothly with lots of sprites on screen.

+3  A: 

The QT Graphics view has collision detection build right in. You don't need a framework for that.

"Graphics View provides a surface for managing and interacting with a large number of custom-made 2D graphical items"

extraneon
At what level is the collision detection done? Bounding box, polygon or pixel?
Skizz
@Skizz - the docs say: QGraphicsItem supports collision detection through the QGraphicsItem::shape() function, and QGraphicsItem::collidesWith(), which are both virtual functions.
SB
@Skizz you can download the sourcecode of Qt as it's double-licensed (GPL included:)
extraneon
What is the best way to do a side-scrolling level, and can the sprites be animated? The collision detection should be at the polygon level.
Tristan Seifert
@Tristan Seifert The view does the scrolling, you just say where to scroll to. And why do you care *how* it does collision detection? As long as it's both accurate and fast. Just have a look at the examples of GraphicsView http://doc.qt.nokia.com/4.6/examples-graphicsview.html.
extraneon
@Tristan Seifert I do believe that the term "polygon" is usually used in 3D, not in 2D Sprite context. Sprites can be (and often are) bitmaps and not so much polygons.
extraneon
By polygon collision detection I mean something that, for example say we had a triangle sprite, but another sprite can, well, slide down it. That's where I need a polygon collision detection. when I wanted to scroll, I have to draw the entire level, and then just scroll>
Tristan Seifert
+1  A: 

It's not a pure-Qt solution, but Gluon is a game development library based on Qt and some of the KDE game libraries

Kitsune
Gluon is nice if you want to click together your games in Gluon Creator, but not if you want to develop against it in C/C++. A lengthy review is on the [kde-games-devel mailing list](http://kde.markmail.org/message/bnibfxyxulqrcpn5).
Stefan Majewsky
A: 

Pixel level collision detection is not too hard to do in 2D games. First off, create a memory buffer the same size as the display. Then, as each sprite is drawn, draw a monochrome version into the memory buffer where the value written is an ID of some sort. To test for collision, check the (x,y) position in the memory buffer for a non-zero value. The value read is the ID of the object.

Skizz
A: 

QGraphicsView is most likely the best choice if you want to put many items on the canvas. If your game contains not too much objects (say, less than 500), you could also consider QML aka Qt Quick (which will be released with Qt 4.7). Also, QGraphicsView has big support in the Qt developer community, so many components are already available (e.g. in libkdegames).

Stefan Majewsky