PDA

View Full Version : Code/tutorial for the developing the "board" part of a board game



SpiceWeasel
23rd November 2015, 20:30
Hello,

I am looking for source code for board games like Life, Sorry, Monopoly, or Risk (or similar turn-based games with a static game board). Specifically, I am trying to figure out how to develop the "board" part of a board game. I am familiar with using a QWidget and its paintEvent() function. I've used that to display a Tic-Tac-Toe board. But I am not sure if using this method is appropriate for a board game that has more complex tiles and tokens and interactions.

I have been looking at QT Graphics View framework; but I have not been able to relate the examples to what I am trying to accomplish. I was hoping there might be QT code out there for a finished board game like the ones I've mentioned above; but it there is, it's well hidden, because I haven't found any after several Google search attempts.

d_stranz
23rd November 2015, 21:29
If your board is static, you could use an image instead of some complex graphics / view construct. If you do want to use graphics view, you could use a QGraphicsPixmapItem as the parent item, and make your tokens and other movable items children of that.

I don't know of any Qt apps where source code is available, but there might be something in KDE (which is Qt-based).

anda_skoa
24th November 2015, 07:43
If you are looking for the source of a Qt board game (or any other type of application) then indeed, as d_stranz already said, it makes sense to look at the code of the biggest Qt Open Source project: KDE.
Since you mentioned Risk: https://www.kde.org/applications/games/ksirk/development

Cheers,
_