clintbellanger / flare

Free Libre Action Roleplaying Engine
http://clintbellanger.net/rpg/
GNU General Public License v3.0
166 stars 41 forks source link

Switch to 1024 units per tile, or use floating point positioning #932

Closed clintbellanger closed 11 years ago

clintbellanger commented 11 years ago

Flare makes a distinction between screen pixels and map units. Each grid square is divided into an internal number of units that represent discrete positions. Using discrete units make some movement and collision routines simple (iterate one unit at a time until colliding with an obstacle, instead of calculating obstacle intersections).

Along with the frameskip option in issue #931, I'd like to convert fantasycore to all 60fps data.

Right now it would be hard to convert to 60fps because the number of discrete units per tile is so small. Right now a slowed zombie might only move 1 unit per frame at 30 fps. If we switched to 60fps, they can't currently move a half-unit per frame. The minimum allowed speed (1 unit per frame at 60fps) wouldn't be slow enough.

Two possible solutions:

  1. Up the number of units per tile to 1024. This gives us plenty of room for maneuvering (essentially like having millimeter units). This may cause some movement calculations to take a bit more time, but I kinda doubt it would be a huge factor. In this scenario, being in the middle of tile 0,0 would be specific location 512,512. To find the whole tile you're on, bitshift right 10.
  2. Change the entire code base to use floating point locations instead. Currently hazards do use floating point positions, but hazards also have simplified movement logic. This would require rewriting some movement routines. In this scenario, being in the middle of tile 0,0 would be specific location 0.5,0.5. To find the whole tile you're on, truncate.

Merits either way? Well if we can get a really clean replacement for the entity movement code, I think floating point positions make more sense. The new movement code would probably use basic geometry to find where the next tile edge is, instead of iterating map units. In addition, Tiled uses floating-point positions for sub tiles, and it's possible we could introduce events locations that aren't snapped to the grid size.

igorko commented 11 years ago

Migrated to clintbellanger/flare-engine#120