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. Sprite in SFML style in Qt6, OpenGL ES 2.0, C++, Python, JavaScript for Android, Desktop, and WebAssembly

Sprite in SFML style in Qt6, OpenGL ES 2.0, C++, Python, JavaScript for Android, Desktop, and WebAssembly

Scheduled Pinned Locked Moved Game Development
6 Posts 2 Posters 673 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #1

    Hello,

    This is my example that I will explain in the current topic. SFML-style means that working with a sprite is like in SFML. There are methods of the Sprite class with the same names like in SFML:

        void setPosition(float x, float y);
        void setSize(float w, float h);
        void setTextureRect(const QString &spriteName);
    

    The example parses a JSON file that was created in FreeTexturePacker.

    Source code on GitHub:

    • OpenGL ES 2.0, Qt6, C++
    • OpenGL ES 2.0, PySide6, Python
    • OpenGL ES 2.0, PyQt6, Python
    • WebGL 1.0, JavaScript

    Executables created by Qt C++:

    • WebAssembly: https://65d032748f92293df6abc084--sweet-pavlova-c68026.netlify.app/
    • EXE for Windows 10, 64-bit: sprite-in-sfml-style-opengles2-qt6-cpp-win10x64-exe.zip
    • APK for Android 7-14: sprite-in-sfml-style-opengles2-qt6-cpp-android-7-14.apk

    a410d42b-b9a2-4478-828b-67b00d95a8b1-image.png

    37d02279-6604-4d35-ac8c-563876b86008-image.png

    1 Reply Last reply
    1
    • 8Observer88 8Observer8 marked this topic as a regular topic on
    • 8Observer88 8Observer8 marked this topic as a question on
    • 8Observer88 8Observer8 marked this topic as a regular topic on
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      While the demonstration is nice, I wouldn't use assets from that company. They are pretty trigger sensitive when it relates to their material.

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

      8Observer88 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        While the demonstration is nice, I wouldn't use assets from that company. They are pretty trigger sensitive when it relates to their material.

        8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by 8Observer8
        #3

        @SGaist I don't know, maybe they don't pay attention if someone makes demos for training and not for selling. I think none of them will find this topic. I’ll try to leave these assets for now, but if someone from their company writes, I’ll replace them with other assets.

        1 Reply Last reply
        0
        • 8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by
          #4

          What is the difference between JSON parsing on PySide6 and PyQt6. On PyQt6 you need to call the toDouble() method, but on PySide6 you don't:

          PyQt6:

          gravity = root["gravity"].toDouble()
          

          PySide6:

          gravity = root["gravity"]
          

          main.py

          import sys
           
          from PyQt6.QtCore import QByteArray, QJsonDocument
          from PyQt6.QtWidgets import QApplication, QWidget
           
           
          class Window(QWidget):
           
              def __init__(self):
                  super().__init__()
           
                  content = "{ \"gravity\": -9.8 }"
                  doc = QJsonDocument.fromJson(QByteArray(content.encode()))
                  root = doc.object()
                  gravity = root["gravity"].toDouble() # PyQt6
                  # gravity = root["gravity"] # PySide6
                  print("gravity =", gravity)
                  print(type(gravity))
           
          if __name__ == "__main__":
              app = QApplication(sys.argv)
              w = Window()
              w.show()
              sys.exit(app.exec())
          
          SGaistS 1 Reply Last reply
          0
          • 8Observer88 8Observer8

            What is the difference between JSON parsing on PySide6 and PyQt6. On PyQt6 you need to call the toDouble() method, but on PySide6 you don't:

            PyQt6:

            gravity = root["gravity"].toDouble()
            

            PySide6:

            gravity = root["gravity"]
            

            main.py

            import sys
             
            from PyQt6.QtCore import QByteArray, QJsonDocument
            from PyQt6.QtWidgets import QApplication, QWidget
             
             
            class Window(QWidget):
             
                def __init__(self):
                    super().__init__()
             
                    content = "{ \"gravity\": -9.8 }"
                    doc = QJsonDocument.fromJson(QByteArray(content.encode()))
                    root = doc.object()
                    gravity = root["gravity"].toDouble() # PyQt6
                    # gravity = root["gravity"] # PySide6
                    print("gravity =", gravity)
                    print(type(gravity))
             
            if __name__ == "__main__":
                app = QApplication(sys.argv)
                w = Window()
                w.show()
                sys.exit(app.exec())
            
            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @8Observer8 Good question, I currently don't know. You would need to compare the bindings generated by each variant to see what is done differently.

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

            8Observer88 1 Reply Last reply
            0
            • SGaistS SGaist

              @8Observer8 Good question, I currently don't know. You would need to compare the bindings generated by each variant to see what is done differently.

              8Observer88 Offline
              8Observer88 Offline
              8Observer8
              wrote on last edited by
              #6

              @SGaist Sorry for misleading you. It was not a question. Just a note.

              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