Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 2D Game resolution and sprite question
QtWS25 Last Chance

2D Game resolution and sprite question

Scheduled Pinned Locked Moved Unsolved General and Desktop
2d graphicstilesresolution
6 Posts 4 Posters 217 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.
  • S Offline
    S Offline
    Saviz
    wrote on 15 Mar 2025, 06:25 last edited by
    #1

    I'm trying to make a 2D game using Qt just for fun. However, since I've never made a 2D game before, there are some important decisions I need to make before starting, and I don't fully understand some aspects. I’d really appreciate any help in clarifying them.

    My question is this:
    Most 2D games recommend a screen resolution of 640×360 because it scales well to many other common resolutions. At the same time, it’s common to use 16×16 sprites since powers of two help optimize performance.

    The problem is that when drawing tiles in my game, I need to determine how many of these tile images are required to perfectly fill the screen in an 2D array with a certain width and height. But if we do the math, 16×16 tiles don’t fit evenly into a 640×360 resolution. So my question is:

    Why is 16×16 commonly chosen instead of something like 20×20?
    Is it okay if I switch to 20×20 instead? (Is this a bad thing to do?)

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goldenhawking
      wrote on 15 Mar 2025, 13:32 last edited by goldenhawking
      #2

      Using graphics-view framework for Widgets or QML , the size of the scene and the sprites is not a important thing . Tile images are not required to perfectly fill the screen , the view port will automatically do that for you . So, 20x20 or 16x16 does not matter, maybe. For 2D games, a larger size of sprites more than 64x64 is very common, I often cut a 256x256 image from website and put it into scratch3 for fun. Scratch 3 is very funny, not only for kids, but also for me -- who don't want to spend too many brain cells on entertainment. If you want to use Qt, start from the examples is a very good idea, for example, the collidingmice example:

      https://doc.qt.io/qt-6/qtwidgets-graphicsview-collidingmice-example.html

      Qt is the best C++ framework I've ever met.

      S 1 Reply Last reply 15 Mar 2025, 15:08
      1
      • G goldenhawking
        15 Mar 2025, 13:32

        Using graphics-view framework for Widgets or QML , the size of the scene and the sprites is not a important thing . Tile images are not required to perfectly fill the screen , the view port will automatically do that for you . So, 20x20 or 16x16 does not matter, maybe. For 2D games, a larger size of sprites more than 64x64 is very common, I often cut a 256x256 image from website and put it into scratch3 for fun. Scratch 3 is very funny, not only for kids, but also for me -- who don't want to spend too many brain cells on entertainment. If you want to use Qt, start from the examples is a very good idea, for example, the collidingmice example:

        https://doc.qt.io/qt-6/qtwidgets-graphicsview-collidingmice-example.html

        S Offline
        S Offline
        Saviz
        wrote on 15 Mar 2025, 15:08 last edited by
        #3

        @goldenhawking I am working on a 2D platformer where precise tile alignment is crucial. The overall screen size is determined by the combination of tile sizes and the number of tiles per row and column, which are calculated dynamically. For reference, I am following a tutorial on YouTube, and here is an example of what I am trying to achieve:

        Sample.png

        Since I plan to create a map system where levels and scenes are defined using a numerical tile-mapping system, the tile sizes must match exactly for everything to function correctly.

        Given this, what would you suggest I do to ensure proper alignment and scaling?

        P 1 Reply Last reply 15 Mar 2025, 18:56
        1
        • S Saviz
          15 Mar 2025, 15:08

          @goldenhawking I am working on a 2D platformer where precise tile alignment is crucial. The overall screen size is determined by the combination of tile sizes and the number of tiles per row and column, which are calculated dynamically. For reference, I am following a tutorial on YouTube, and here is an example of what I am trying to achieve:

          Sample.png

          Since I plan to create a map system where levels and scenes are defined using a numerical tile-mapping system, the tile sizes must match exactly for everything to function correctly.

          Given this, what would you suggest I do to ensure proper alignment and scaling?

          P Online
          P Online
          Pl45m4
          wrote on 15 Mar 2025, 18:56 last edited by
          #4

          @Saviz

          I don't have the right links at hand but there are Super Mario "clones" / arcade games out there, which are probably what you are looking for.
          With some research you should be able to find them. Can't remember the name actually. But there are definitely more than a few.
          Maybe you can look there how its done.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          S 1 Reply Last reply 15 Mar 2025, 19:27
          1
          • P Pl45m4
            15 Mar 2025, 18:56

            @Saviz

            I don't have the right links at hand but there are Super Mario "clones" / arcade games out there, which are probably what you are looking for.
            With some research you should be able to find them. Can't remember the name actually. But there are definitely more than a few.
            Maybe you can look there how its done.

            S Offline
            S Offline
            Saviz
            wrote on 15 Mar 2025, 19:27 last edited by
            #5

            @Pl45m4 I will try, but the problem is that I cannot find a full resource that explains every part of how to actually achieve this, from the screen size to sprite size to the overall architecture. Seems like a challenge.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jeremy_k
              wrote on 15 Mar 2025, 21:46 last edited by
              #6

              I'm under the impression that supporting multiple resolutions is often accomplished by shipping several sizes of image assets. Unless the target platform is space constrained or the sprite set is large, the cost is trivial.

              The concept of mipmapping might be of interest.

              Asking a question about code? http://eel.is/iso-c++/testcase/

              1 Reply Last reply
              0

              4/6

              15 Mar 2025, 18:56

              • Login

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