Skip to content

Game Development

What can we say - we like games. And you can use Qt to write some. Questions? Ask here.
837 Topics 4.0k Posts
  • how to make a turn-based battle system

    Unsolved
    8
    0 Votes
    8 Posts
    530 Views
    D

    The signal emitted can be caught by a class that controls the QPainter, the slot can be as such

    Class visualizer { Public slot: Void character_health_affected { //show blood or shake effect styled images //timeout the blood, hide/delete blood effects after a few seconds } }
  • 0 Votes
    3 Posts
    378 Views
    D

    @Chris-Kawa wow I can’t believe I missed that.
    I’m sure that is the issue, I will try this solution right away.

  • could someone tell me how i apply the state machine

    Unsolved
    6
    0 Votes
    6 Posts
    389 Views
    JonBJ

    @milhao
    Have you had a look at, say

    https://doc.qt.io/qt-5/qtwidgets-statemachine-eventtransitions-example.html https://cpp.hotexamples.com/examples/-/QStateMachine/-/cpp-qstatemachine-class-examples.html
  • Help with QPainter arc math

    Unsolved
    2
    0 Votes
    2 Posts
    217 Views
    S

    Sorry, I should have provided some code to test it.

    #include <QtWidgets> unsigned long f = 0; class Character : public QWidget { public: Character(); ~Character(); QPixmap *getPixmap(); protected: void paintEvent(QPaintEvent *e); }; Character::Character() : QWidget(){} Character::~Character(){} void Character::paintEvent(QPaintEvent *event){ Q_UNUSED(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setBrush(QBrush(QColor(255, 255, 255))); painter.drawEllipse(QRectF(0, 0, 79, 79)); for(int i = (f % 10); i <= 80; i += 10){ if(i<50) painter.drawArc(0, i, 79, 80-i*1.5, 0, 180*16); else painter.drawArc(0, 50-(i-50), 79, (i-55)*2, 180*16, 180*16); } painter.end(); f++; } int main(int argc, char *argv[]){ QApplication app(argc, argv); Character *c = new Character(); QTimer t; QObject::connect(&t, &QTimer::timeout, c, static_cast<void(QWidget::*)()>(&QWidget::update)); t.start(30); c->show(); return app.exec(); }
  • How to change texts and image by button multiple times

    Solved
    10
    0 Votes
    10 Posts
    707 Views
    SGaistS

    Sure you can use the same button for the sequence.

  • how to check the output of the QCombobox box

    Solved
    5
    0 Votes
    5 Posts
    374 Views
    ApprenticeRenoA

    @milhao
    I assume you drag and drop a comboBox in you're ui.file and then set the items, if this is you're case you can try :

    -Go to the ui.file , right click on the comboBox , GoToSlot -> select on CurrentTextChanged, then , in the method that is created automathically you write this:

    void MainWindow::on_comboBox_1_currentTextChanged(const QString &arg1) { if(ui->comboBox_1->currentText()=="elf"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); }else if(ui->comboBox_1->currentText()=="human"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); } }
  • 0 Votes
    1 Posts
    245 Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    8Observer88

    The falling COLLADA (.dae) cube using PySide6, PyQt6, Bullet Physics, and OpenGL 3.3:

    PySide6: https://github.com/8Observer8/falling-collada-cube-bullet-physics-opengl33-pyside6 PyQt6: https://github.com/8Observer8/falling-collada-cube-bullet-physics-opengl33-pyqt6

    You should install these packages:

    pip install PySide6 (or PyQt6) pip install PyOpenGL pip install numpy pip install Panda3D (for Bullet Physics)

    falling-collada-cube.gif

  • 0 Votes
    5 Posts
    2k Views
    8Observer88

    A few basic changes in PyQt6 regarding shader-based OpenGL graphics

  • QMaterial with just a rhi technique

    Unsolved
    1
    0 Votes
    1 Posts
    180 Views
    No one has replied
  • Another 2D Game

    Unsolved
    3
    2 Votes
    3 Posts
    423 Views
    I

    @QtLukasz Looks interesting

  • 0 Votes
    5 Posts
    531 Views
    K

    I found out what was the problem:

    The Window, which hosts the layout in which the 3D Widget is set, contains the following statement in the constructor:

    setWindowState(windowState() | Qt::WindowMaximized);

    or..

    setWindowState(Qt::WindowMaximized);

    I removed this statement and the 3D Window now shows the content.

    This is not happening in the Linux build!

    Now, both builds work correctly.

    Issue is solved.

  • Qt3D example using QSkeleton QArmature?

    Unsolved
    1
    0 Votes
    1 Posts
    220 Views
    No one has replied
  • 0 Votes
    5 Posts
    460 Views
    B

    @JonB You’re right, Thanks, QGraphicsItemGroup did the trick. I just needed to set the transform origin point to the centre of the red rectangle. Now the desired effect is achieved by this code:

    #include "game.h" #include <QGraphicsItemGroup> QGraphicsItemGroup* g = new QGraphicsItemGroup; Game::Game() { player = new QGraphicsRectItem(); rectItem = new QGraphicsRectItem(); m_view = new QGraphicsView(this); m_view->setSceneRect(QRectF(0,0,800,600)); this->setBackgroundBrush(Qt::black); m_view->setScene(this); m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); m_view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate); m_view->show(); player->setRect(0,0,100,100); player->setBrush(Qt::red); player->setPos(400,300); player->setFocus(); rectItem->setRect(0,0,100,100); rectItem->setBrush(Qt::green); rectItem->setPos(400,330); this->addItem(g); player->setZValue(10); rectItem->setZValue(1); g->addToGroup(player); g->addToGroup(rectItem); g->setTransformOriginPoint(player->pos().x() + player->boundingRect().width()/2 ,player->pos().y() + player->boundingRect().height()/2); } void Game::advance() { } void Game::keyPressEvent(QKeyEvent *event) { switch(event->key()) { case Qt::Key_Left : g->moveBy(-5,0); break; case Qt::Key_Right : g->moveBy(5,0); break; case Qt::Key_Up : g->moveBy(0,-5); break; case Qt::Key_Down : g->moveBy(0,5); break; case Qt::Key_Q : g->setRotation(g->rotation()- 3); break; case Qt::Key_W : g->setRotation(g->rotation() +3); break; } update(); }
  • Qt3D - [c++] Q: How to activate shadow mapping

    Unsolved
    6
    0 Votes
    6 Posts
    603 Views
    BondrusiekB

    @kevin_d
    I dont know this topic well but recommend you see : https://doc.qt.io/qt-6/qsgmaterialshader-graphicspipelinestate.html
    or use some environments like ie

    qputenv("QT3D_GLSL100_WORKAROUND", "");

    The qputenv("QT3D_GLSL100_WORKAROUND", "") instruction is a workaround related to Qt3D
    shaders on some embedded Linux devices, such as the Raspberry Pi. It will enable a separate
    GLSL 1.00 snippet for the lights required by some embedded devices.
    Maybe you must see this kind of variables.

  • 0 Votes
    1 Posts
    357 Views
    No one has replied
  • [Euler angles values are incorrect]

    Unsolved
    1
    0 Votes
    1 Posts
    279 Views
    No one has replied
  • 0 Votes
    3 Posts
    239 Views
    K

    Finally the scene gets properly rendered by explicietely setting the QSortPolicy on the frameGraph:

    Qt3DRender::QFrameGraphNode *framegraph = view.activeFrameGraph(); Qt3DRender::QSortPolicy *sortPolicy = new Qt3DRender::QSortPolicy(scene); framegraph->setParent(sortPolicy); QVector<Qt3DRender::QSortPolicy::SortType> sortTypes = QVector<Qt3DRender::QSortPolicy::SortType>() << Qt3DRender::QSortPolicy::BackToFront; sortPolicy->setSortTypes(sortTypes); view.setActiveFrameGraph(framegraph);
  • High CPU usage

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    J

    @Darksorrow said in High CPU usage:

    If i can't figure this out i think i'll go back to use OpenGL directly >.<

    I have the same problem>.<!
    Any good results?

  • 0 Votes
    3 Posts
    313 Views
    K

    If you like to have a look on how the scene-loader works with nested objects and materials, have a look on the topic:

    https://forum.qt.io/topic/134729/q-qt3d-c-apply-qmaterial-on-a-loaded-obj-file/3