C++ 使用 Qt 开发游戏:先看哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2224155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Game development with Qt: where to look first?
提问by Pym
So, I'm going to develop a Pac-Man clone with Qt. The problem is that I do not really know where to start.
所以,我将用 Qt 开发一个 Pac-Man 克隆。问题是我真的不知道从哪里开始。
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!
我快速查看了文档和一些演示。我还在 qt-apps.org 上下载了一些游戏源。而且好像用Qt开发游戏的方法有很多!
In your experience, which part of Qt should I consider to develop a Pac-Mac clone ?
根据您的经验,我应该考虑 Qt 的哪个部分来开发 Pac-Mac 克隆?
- The Animation Framework
- The Graphics View Framework
- The Paint System
- Qt Declarative
- 动画框架
- 图形视图框架
- 油漆系统
- Qt声明式
Any help would be appreciated.
任何帮助,将不胜感激。
采纳答案by Tadeusz A. Kad?ubowski
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.
我认为QGraphicsView框架是最好的方法。创建一个QGraphicsScene,一些 QGraphicsItems 用于游戏元素。您可以免费进行碰撞检测。
Most of KDE gamesare based on the QGraphicsView framework. It is a good fit for simple game development.
大多数KDE 游戏都是基于 QGraphicsView 框架的。它非常适合简单的游戏开发。
回答by alexleutgoeb
I'm currently working on a project providing gaming-specific Qt Quick Components for cross-platform game development, might be of interest: http://v-play.net:)
我目前正在为跨平台游戏开发提供特定于游戏的 Qt Quick Components 的项目,可能会感兴趣:http: //v-play.net:)
回答by Matt
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 QTimerto 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.
至少你会想看看QGLWidget。您可以通过从 QGLWidget 派生在几分钟内启动 OpenGL 程序,它将创建窗口、上下文、处理鼠标和键盘输入等。创建一个QTimer以每 10-15 毫秒左右触发一次 updateGL() 和您的好去。我认为某处有一个演示用于设置它,但我已经有一段时间没有看到它了。
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.
如果您想将小部件嵌入窗口,我会查看QGraphicsView。有一个名为box的演示。请注意,该演示有点难以学习,因为将多个类放入同一个文件中,并且可能需要花一些时间进行跟踪才能找出流的位置。
Since you are doing a 2d game, you might want to look at using QPainteron 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.
既然你在做一个2D游戏,你可能想看看使用的QPainter上的OpenGL的顶部。这使您可以轻松地绘制图元,而不是使用 OpenGL 调用来进行绘制。不过,我永远无法让它在全屏模式下停止闪烁。
回答by Nikola Kotur
回答by Lucas
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
我正在使用 Nvidia 的 PhysX API 开发带有 Qt 和 OpenGL 的刚体模拟。如果你想看到这种方法,看看我在 github 上的项目:http: //github.com/lucassimao/Simulacao-Estereologica
回答by stacker
A good start would be:
一个好的开始是:
Perhaps if you need to cheat you may want to look here xpacman.tar.gz
也许如果你需要作弊,你可能想看看这里 xpacman.tar.gz
回答by leinir
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
好吧,一个可以查看的地方可能是目前正在开发的 Gluon 游戏开发框架。这取决于您对 PacMan 克隆的真正目标是什么,但 Gluon 很可能就是您所追求的:https: //github.com/KDE/gluon
回答by MeLikeyCode
If anyone else is interested in learning how to make GAMES using C++ and Qt, have a look at my YouTube tutorial series. It explains the graphics view framework through a series of videos which build upon a single game that we start in tutorial 1.
如果其他人对学习如何使用 C++ 和 Qt 制作游戏感兴趣,请查看我的 YouTube 教程系列。它通过一系列视频解释了图形视图框架,这些视频基于我们在教程 1 中开始的单个游戏。
C++ Qt Game Tutorial 8 - Adding Graphics
If you are not comfortable with Qt yet, then I REALLY loved VoidRealm's Qt tutorial series, also on youtube (C++ Qt 1 - Introduction to QT programming).
如果你还不习惯 Qt,那么我真的很喜欢 VoidRealm 的 Qt 教程系列,也在 youtube 上(C++ Qt 1 - QT 编程简介)。