Game Development Community

Tile Mapping: Square Grid vs. Offset Row Square Grid

by Tim Doty · in Torque Game Builder · 03/04/2005 (8:36 pm) · 4 replies

First, note that I haven't had enough time to fully come to grips with T2D so maybe I've missed something, but:

As I alluded to in a different thread... I was researching collision detection and ran across one of the .plans for T2D. As the engine, even the early adopter, is far more powerful than what I was planning I immediately purchased it. I like T2D and because it is so quick to come up with something I've got an idea that I'm pursuing with it to get my feet wet. For the original project...

T2D is powerful, but there are different approaches. I've played in and run various paper and pencil roleplaying games for 25+ years. I've been designing them (in house only) for most of that. I love systems so I was always coming up with new ones. I decided to "fully complete" a game design and this has been my baby since 1998. What does this have to do with T2D? I'm working on doing an (as full as possible) implementation of it as a computer game.

Most computer "roleplaying" games are really action or adventure games. I'm aiming for an actual roleplaying game. So what does this mean? First and foremost it is a refereed multi-player game. It needs to have a way for conversations. I've written up the basic code for this using the SDL. T2D itself doesn't seem to have any text handling at all, but integrating the C/C++ code shouldn't (?) be that hard. I don't know because I've only skimmed the source for T2D.

A second point is that I'm trying to adapt the paper and pencil system to a computer. This means some things can be done that aren't reasonable with paper and pencil (some of the math, for example, or integers vs. floating point). The map class I wrote uses staggered rows of square tiles as an approximation for hexes.

Why do I care? Because hexes are central to a lot of the rules dealing with location, movement and area. For instance, a spell may be able to affect 12 contiguous hexes. An item, object, creature, etc. is affected if it is in one of those hexes. Without a rigorous definition of hex I don't see how that can be done. Although offset rows of square tiles are not a perfect match for hexes they are IMO a close enough approximation.

This is what I meant in the other thread about basic design: T2D uses normal square grids. Using offset rows requires a change in math, a change in representation. Its not a big deal but it *is* basic.

Would I like to use T2D for this? You bet I would. Although not necessary for what I set forth to do, having particle effects, for example, allows visualization of so much more. I doubt I'd have messed with animated sprites, either. Its a matter of focus and when you're writing the whole thing yourself you focus on what needs to be done to achieve the objective. OTOH with T2D I *can* do all of that because I'm not having to code the basics.

Maybe I've missed something in T2D, its very possible. I haven't had it long and other tasks intrude. Fundamentally all game writing I do is hobby.

I figure by writing a much less ambitious game using T2D I don't lose much dev time and I gain some knowledge and understanding of it to see if I *can* adapt it to my needs. I'm happy to get any feedback on any of this.

#1
03/05/2005 (9:53 am)
I'm not quite sure what you mean by offset rows. But as far as hexagonal tiles go, we do plan to implement non rectalinear tiles. Can't say when, there are lots of things to get done, but just so you know, you could mock-up / prototype with things as they stand now, and then either look at doing hex tiles yourself, waiting for the official implementation, or deciding that maybe your gameplay works on square (and/or offset?) tiles. :)

I'd love to see a nice RPG in T2D, so feel free to ask questions any time!
#2
03/05/2005 (3:29 pm)
Well, if you do implement hexagonal then that would solve that issue. As I said, the offset rows is just an approximation. What I mean by offset rows is this:

Take a square grid. Every other row gets offset by 1/2 the width. Compare this to a hex-map where the hex rows run horizontally. You'll see that (boundary shape issues aside) they map the same space. Each square is bordered by six other squares. Its a trick I saw years ago in Basic Role-Playing by Chaosium, I didn't think of it. If you're not concerned with the boundary shape issue (and for this I'm not really worried) it avoids the overhead of actually doing hexes.
#3
03/05/2005 (11:46 pm)
Oh I gotcha Tim. If you wanted to do that, I suppose you could chunk your tiles up into 3 sub-sections.. then treat 2 tiles at a time together in your code.. so the first row takes tile pairs 1-2, 3-4, 5-6, etc; row 2 takes pairs 2-3, 4-5, 6-7, etc. Something like that sounds like it'd get ya where you want to be.

I forgot to mention re: text-handling.. if you mean font support, that is *very* high on our priority list. Just to let ya know.
#4
03/06/2005 (12:30 pm)
@Josh: Hmm, that'd work. As for text-handling: cool!

@Robert: I've got code for doing true hexes, but as I wasn't planning on displaying them (just using them for the backend rules) I figured it made sense to use the more efficient method (offset rows being slightly more efficient). Thanks for the link in any case -- I may get ideas.