Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Loop Run

Loop Run

Scheduled Pinned Locked Moved Game Development
16 Posts 8 Posters 5.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Everton FonsecaE Offline
    Everton FonsecaE Offline
    Everton Fonseca
    wrote on last edited by
    #3

    I'm looking this way

    // Qml javascript
    item{

    // init object
    

    Component.onCompled: {

     // here being a parallel thread
      While (runningGame)
     {
           Update ()
           ...
           Sleep SPF 60
        
     } // end while
    

    } // end event onCompled

    } // end Item

    This is possible to do, do you have any example of a game in the qml that does it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      No, I don't have any example doing it like that and I don't think it's a good idea either.

      What would you do in that loop ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Everton FonsecaE Offline
        Everton FonsecaE Offline
        Everton Fonseca
        wrote on last edited by
        #5

        Update all objects

        mrjjM 1 Reply Last reply
        0
        • Everton FonsecaE Everton Fonseca

          Update all objects

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @Everton-Fonseca
          But any object will update/draw itself is its state changes?

          1 Reply Last reply
          1
          • Everton FonsecaE Offline
            Everton FonsecaE Offline
            Everton Fonseca
            wrote on last edited by
            #7

            That same design change status, how do I do that?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              What kind of update do you have in mind ?

              Here you have a small game sample that doesn't need any infinite loop.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              Everton FonsecaE 1 Reply Last reply
              2
              • tekojoT Offline
                tekojoT Offline
                tekojo
                wrote on last edited by
                #9

                It sounds like you are thinking in the traditional way (the way people think of real time operating systems).

                QML wasn't designed with this idea in mind. It goes design and objects first. The framework will then get you the FPS your hardware can handle (probably 60, or whatever your graphics card usually outputs to your monitor).
                Of course QML provides timers, but they also work automatically, you do not need to "sleep" them.

                1 Reply Last reply
                2
                • SGaistS SGaist

                  What kind of update do you have in mind ?

                  Here you have a small game sample that doesn't need any infinite loop.

                  Everton FonsecaE Offline
                  Everton FonsecaE Offline
                  Everton Fonseca
                  wrote on last edited by
                  #10

                  thanks = D

                  1 Reply Last reply
                  1
                  • G Offline
                    G Offline
                    Galbarad
                    wrote on last edited by
                    #11

                    i'm using timer for updating game state
                    30 mks give 33FPS and this working on mobile

                    Timer {
                            id: tMain;
                            interval: 30;
                            running: false;
                            repeat: true
                            onTriggered: {
                                var diff = Qt.core.move();
                                if (diff > 0) {
                                    CTL.checkGameState(diff);
                                }
                            }
                        }
                    

                    my game with main loop in timer
                    https://play.google.com/store/apps/details?id=net.is.games.CatchTheGhost

                    Everton FonsecaE 1 Reply Last reply
                    1
                    • G Galbarad

                      i'm using timer for updating game state
                      30 mks give 33FPS and this working on mobile

                      Timer {
                              id: tMain;
                              interval: 30;
                              running: false;
                              repeat: true
                              onTriggered: {
                                  var diff = Qt.core.move();
                                  if (diff > 0) {
                                      CTL.checkGameState(diff);
                                  }
                              }
                          }
                      

                      my game with main loop in timer
                      https://play.google.com/store/apps/details?id=net.is.games.CatchTheGhost

                      Everton FonsecaE Offline
                      Everton FonsecaE Offline
                      Everton Fonseca
                      wrote on last edited by
                      #12

                      well very good, thanks = D brother

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        Suares
                        wrote on last edited by
                        #13

                        @Everton-Fonseca
                        I would suggest moving your main game loop from qml to C++ code. It's only my suggestion.
                        I think you've already checked this but one more time here is good explanation how you can get 60 FPS.
                        Use Qt Quick module only for rendering. Ideally logic should be written in C++ IMHO.

                        Everton FonsecaE 1 Reply Last reply
                        0
                        • S Suares

                          @Everton-Fonseca
                          I would suggest moving your main game loop from qml to C++ code. It's only my suggestion.
                          I think you've already checked this but one more time here is good explanation how you can get 60 FPS.
                          Use Qt Quick module only for rendering. Ideally logic should be written in C++ IMHO.

                          Everton FonsecaE Offline
                          Everton FonsecaE Offline
                          Everton Fonseca
                          wrote on last edited by
                          #14

                          @Suares
                          thanks = D

                          1 Reply Last reply
                          0
                          • GTDevG Offline
                            GTDevG Offline
                            GTDev
                            wrote on last edited by
                            #15

                            If you're interested in game development with Qt, you can also have a look at V-Play Engine. V-Play also has some good tutorials to show how to implement games with mainly QML.

                            Best,
                            GT

                            Senior Developer at Felgo - https://felgo.com/qt

                            Develop mobile Apps for iOS & Android with Qt
                            Felgo is an official Qt Technology Partner

                            1 Reply Last reply
                            1
                            • johngodJ Offline
                              johngodJ Offline
                              johngod
                              wrote on last edited by
                              #16

                              From my experience, QML timer is all but accurate betwen plataforms.
                              I have experienced significant speed diferencies between linux and windows, wich makes the game characters move with very diferent speeds on diferent plataforms. This can be a problem and make the game unplayable.

                              Iinitially I tought that Timer was just a QTimer exposed to QML, but has AFAIK thet are not related at all.
                              QTimer seems to provide a much better accuracy, so what I did was to created a new c++ class that uses QTimer, and expose it to QML. In the end, I got a MyTimer qml entity with similar Timer sintaxe, but with much better results.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved