Collision Data - pk-hack/CoilSnake GitHub Wiki

Every 32x32 map tile in EarthBound lets you specify the collision for each 8x8 tile in it individually. This collision data is also sometimes called "surface flags" in some contexts, because it takes the form of bit flags for each tile. That means, the different digits that up a single collision entry in binary mean different things! Here's what each binary digit, or bit, does. (Numbers are shown in hex, which is what EB Project Editor uses, and then followed by the same number in binary.)

  0x80 (10000000) = Solid collision
  0x40 (01000000) = Very solid collision (behaves the same as 0x80 in most ways)
  0x20 (00100000) is not used for anything
  0x10 (00010000) = A "map object" (door/ladder/stairs) can be placed here
  0x08 (00001000) = Water
  0x04 (00000100) = Walking here will give you sunstroke
  0x02 (00000010) = Hide the top halves of sprites behind this tile's foreground layer
  0x01 (00000001) = Hide the bottom halves of sprites behind this tile's foreground layer

You can add these bits together in a programmer calculator (set to "hex" mode, since the 10/20/40/80 are hexadecimal numbers) to turn on each effect you want individually. You'll end up with one 8x8 collision tile that does all of the effects you want at once. Here are some examples:

  • Say you want a door, and you don't want the player to be able to walk on top of it around the 8x8 area where it is. You can combine 10 (map object presence) with 80 (solid collision): 0x10 + 0x80 = 0x90. That means a collision of 90 can be used for a door that the player can't walk around on.
  • Say you want a door for a secret shack hidden in the trees, where you can't see the player. You can combine 01 (hide sprites' bottom halves) + 02 (hide sprites' top halves) + 10 (allow a map object to be placed here) to get 13, and place that where the door is.
  • Say you want an "anti-tree" that makes the sun feel really hot when you step into its "shade." Depending on the height of the tree, you'll want the player to appear behind it using either 01 by itself or 01 + 02. (We'll assume it's a short tree, the size of a Territorial Oak enemy, and just use 01.) You can combine this with 04 (terrain damaging effects): 01 + 04 = 05. Stepping on a tile with 05 collision will both hide the bottom half of the player's sprite and occasionally give the player sunstroke.

All of these effects are mostly independent, but there are a few notable combinations:

  • Using both 0x80 ("solid") and 0x02 ("hide sprites' top halves") makes a tile act as a "countertop." You can talk to NPCs that are on the other side of a countertop, unlike through other types of solid collision. If you don't want this for your tile, use 0x40 ("very solid") instead of 0x80. This is the only difference between 0x40 and 0x80.
  • Using both 0x08 ("water") and 0x04 ("sunstroke") combine to make 0x0C, which will not give you sunstroke. Instead, it acts as "deep water" that causes you to lose HP.

A list of a few common combinations of the options, explained in different words, is given below.

  00 = a walkable space
  01 = a tile in which the object featured will appear on top of you. (Such as walking behind a building with only your head poking out, tree top covering your lower body, a fence, a mailbox, etc.) 
  03 = same as 01 except this is needed to completely cover a sprite
  04 = desert (Makes you sweat and makes you vulnerable to sunstroke)
  08 = waist-high water (Makes sprites in it sink to their waist, as in Fourside Sewers, and shallow Deep Darkness water.) 
  09 = same function as 01, only in the waist-high water context (shallow water with foreground)
  0b = same function as 03, only in the waist-high water context 
  0c = deep water (submerges your whole body and makes you take damage)
  0d = same function as 01, only in the deep water context (deep water with foreground)
  0f = same as 03, only in the Deep Water context
  10 = ladder/stairs/rope/door/etc.
  80 = non-walkable tile (Walls and structures. Messianic describes it as "solid and impassible")
  82 = non-walkable tile (used in desks and bars - a solid space you can interact with and talk to the sprite on the other side of it)
  90 = same as 10, but also a non-walkable tile

TODO: do some more experimenting and word these in a better way