Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Alternatives to Tile Based Maps

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Alternatives to Tile Based Maps
Tobias Dammers
Member #2,604
August 2002
avatar

IIRC, the Sonic The Hedgehog are tile-based with more-or-less arbitrary slopes as well. Even if you have vector-based collisions inside each tile, the tile map still makes sense in terms of speeding up calculations (by avoiding unnecessary calculations).
Suppose you have a character that is not larger than the tile size. Then for each movement, you need to check only 4 tiles, instead of the whole map - which can make a difference of 2 vector-based collision checks against 2000, all for the tiny effort of finding the tiles you're on.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Thomas Harte
Member #33
April 2000
avatar

Quote:

IIRC, the Sonic The Hedgehog are tile-based with more-or-less arbitrary slopes as well. Even if you have vector-based collisions inside each tile,

As I understand it, Sonic uses pixel based collisions, but retains a separate normal for each collision pixel.

Quote:

the tile map still makes sense in terms of speeding up calculations (by avoiding unnecessary calculations). Suppose you have a character that is not larger than the tile size. Then for each movement, you need to check only 4 tiles, instead of the whole map - which can make a difference of 2 vector-based collision checks against 2000, all for the tiny effort of finding the tiles you're on.

But no half-decent vector map system would ever do the full 2000 checks and in any case the fact that something is faster doesn't necessarily make it better. It's faster to use 640x480 than any higher resolution but that still doesn't mean it is worth recommending. The principle is whether something is fast enough, which vector maps are – even on a tiny ARM like in the GBA. Look at it another way - what do you suddenly have processor time to do on a tile map that you cannot do on a vector map?

Richard Phipps
Member #1,632
November 2001
avatar

How would you reduce the unnecessary checks Thomas? Some kind of sector system? Could each tile have with it associated vectors, or is that too confining?

I don't think there is a tilemap vector system available for Allegro is there?

Audric
Member #907
January 2001

Damian Grove could answer any questions about the internals of Sonic.
He made a thread there which ends with some technical formula for slopes, but I'm still puzzled by the presence of floating arithmetics and sin function. (I wonder how he can get the same results on an x86 and on 16bit CPU. Does the console even HAVE floating-point arithmetics?)
His blog shows he's still working on it, there's just a recent screenshot of a tile's mask (?).

HoHo
Member #4,534
April 2004
avatar

Quote:

How would you reduce the unnecessary checks

Quadtree?
If you know where some moving entity is you don't even need to traverse the entire tree every time, just reuse the last location and update it when needed. I think it's quite simple to move from one branch to another quite easily assuming you have a good data layout in memory.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Thomas Harte
Member #33
April 2000
avatar

Quote:

Quadtree?
If you know where some moving entity is you don't even need to traverse the entire tree every time, just reuse the last location and update it when needed. I think it's quite simple to move from one branch to another quite easily assuming you have a good data layout in memory.

The "Allegro demo game" (I don't have a better name for it) uses quadtrees for collisions and drawing, but isn't smart enough to factor in frame to frame position coherences.

As you'll be aware but is worth pointing out for the purposes of discussion, quadtrees are good because you effectively place a limit on the number of checks you want to do, rather than picking an arbitrary size of space that you think it would be nice to use for sectors. This also makes them (usually) more memory efficient than a straight sector system.

Even without coherences, you can find the node that a point is in in at worst log4(n) time where n is the maximum subdivisions of the tree. It is normal to have a maximum subdivision beyond which it isn't worth going because you end up dealing with stupidly tiny portions of space.

The "demo game" actually cheats a little - it uses slightly overlapping nodes that allow for the size of the only object that collisions are done with. But whatever.

That code can be seen at https://svn.sourceforge.net/svnroot/alleg/demos/skater/src/quadtree.c - it's reasonably compact and one of those nice things that you write once and then it automatically scales itself.

Richard Phipps
Member #1,632
November 2001
avatar

That code can be seen at https://svn.sourceforge.net/svnroot/alleg/demos/skater/src/quadtree.c - it's reasonably compact and one of those nice things that you write once and then it automatically scales itself.

While it seems nicely commented, it's a bit over my head.

Neil Walker
Member #210
April 2000
avatar

Very much not what is required but pixellate has a little section on slopes:

http://pixwiki.bafsoft.com/mags/14/articles/jnrdev2/index.html

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

 1   2 


Go to: