2D Game resolution and sprite question
-
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 of640×360
because it scales well to many other common resolutions. At the same time, it’s common to use16×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?) -
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
-
@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:
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?
-
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. -
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.