sdl - When coding a game, what am I supposed to use as units? -


i've been using pixels units aspects of game such movement, i've been told bad practice. however, i've never seen explanation on i'm supposed instead. can provide explanation on how handle units in games?

it doesn't matter units use; can arbitrary. thing need make sure not fixed screen pixels, because later find out want change scale of things displayed. it's ok if conversion factor happens 1; make sure conversion exists, can change if have reason later.

(and, practical matter, don't make conversion 1 because hides bugs if forgot convert in 1 place.)

  • for 3d realistic games, common unit "1 meter". real world units don't matter, idea use unit similar size of objects in world.

  • for tile-based or voxel-based games, common unit width of 1 tile. allows omit conversions, you're less have problem tying tiles pixels because tiles affect game rules anyway.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -