Case study: glitched tiles

Talk about the classic version of Metanet Software's amazingly popular freeware platformer right here!
User avatar
The Dreamster Teamster
Posts: 84
Joined: 2010.06.28 (22:53)
NUMA Profile: http://nmaps.net/user/atomizer
Steam: https://steamcommunity.com/id/_atomizer
MBTI Type: INTP
Contact:

Postby atomizer » 2011.09.06 (19:51)

I guess this is the right place to post this.

Case study: glitched tiles

Disclaimer: these are the "true" glitched tiles, i.e. produced by tileset code. Something about the artifical NaN-trapdoor generated GTs will be added later if there's anyone interested in those.

Lately I was porting parts of N engine to JavaScript, and decided to use it to pursue some of the bugs of the engine and get to know better how they work. Since there is not much info about the glitched tiles (GT), I decided to start with them.


Preface

True GT is a tile with ID higher than those of "5" tiles. When a GT is initialised, the type identification code block is skipped to the last part, where it is assumed that it is a "5" tile, which is the cause for the glitched tiles to exist. The difference in the command flow from the "5" tiles is that the only properties that are set up are the general type and the sprite, which is set equal to "5Q" tile regardless just because it has the highest index in the bank. (The sprite, as you might have already noticed, does not depict any of the physical properties of the GT, it is just a confusing picture.) All the other properties are left intact, so if there was a tile, it's sx, sy, signx and signy are inherited by the glitch tile (more on that below). This results in existence of two major types of glitched tiles:
  • clean: fully symmetric, has 8 corners (it's not a typo, read on) and no solid edges nor body.
  • dirty: diagonal symmetry (4 possible orientations), has 2 proper solid edges and 3 corners, the body is of a complex shape and doesn't have stable edges.
The existence of this side effect of previous state of the grid is why the maps with GTs in them need to be loaded after a so-called "preloader", the tileset which creates conditions for right types of GTs to spawn (usually just an empty map, since the second type is never used).


How to create a GT

Replace one of the symbols in the tile code with a symbol which code is higher than that of a uppercase Q (for example, it can be any lowercase letter). It doesn't matter which symbol you choose, the only requirement is stated above.

Now, how to create a certain type of glitched tile? There are three possible outcomes for the GTs in the second tileset, depending on the first tileset (the preloader):
  • "5" tiles from the first tileset remain the same (Physically. The sprites always change to 5Q, remember?)
  • empty ("D") or full ("E") tiles give clean GTs
  • any other tiles give dirty GTs; the solid 90 degree corner present in the original tile remains in the same place - that's how you get 4 sorts of DGTs

Inner workings, exposed

First, let's get familiar with notation of the collision maps I made. Here are two legit tiles on a 3x3 grid, simulated and in-game:

Image Image
  • white pixels are placed where the function QueryPointvsTileMap returns true. That is, the game's AI (rocket, gauss, etc) thinks that those parts of tileset are solid (which is true for legit tiles).
  • blue and black lines are tile edges. In the game there are three types of them: "off", "solid", and "interesting". Solid edges are shown as black, interesting as blue. Solid edges are most important: they're a certain obstacle on anyone's way.
  • colored pixels show direction (hue) and strength (lightness) of the force which the game will apply to a ninja if her center happens to be in those coordinates. Use the outer walls' colors as a guide to determine direction easily.
  • gray pixels are where ninja's movement is not affected by the tileset in any way.
Okay, down to the business:

Clean GT

Here's a collision map of a door, a "E" tile and a clean glitched tile:

Image Image

The CGT has 8 corners: 4 like a E tile, and 4 in the middle of each side similar to door's edges. These corners, when approached from appropriate directions, work exactly the same way as the usual ones. But if you approach them from inside or from the side (anywhere where there is an edge between gray and color) you'll get propulsion in the direction of the corner, the higher gradient - the more propulsion. Also note that you can slip inside and out of the CGT unaltered through tiny openings between "force caps" and corners.
As you can see from white pixels, the game's AI does not discern between a E tile and a CGT, so you can sit inside/behind a CGT without drawing attention.

Dirty GT

A "1W" tile and a dirty GT:

Image Image

This one has 2 edges connected by 3 corners which are exactly the same as on the other tiles. The other side of it, though, presents us a diagonally oriented forcefield with rather high gradient followed by an area of great force which kills N immediately on contact - that's why this type of GT is not very useful. An interesting thing about these is that the "filling" has the same orientation regardless of the tile's orientation, as seen below:

Image Image

The "1" tiles and dirty GTs are the same from game's AI viewpoint.


Practical value of all this

none?

User avatar
Admin
Admin
Posts: 2332
Joined: 2008.09.27 (16:53)
NUMA Profile: http://www.nmaps.net/user/Aidiera :3
Steam: www.steamcommunity.com/id/
MBTI Type: INTJ
Location: Phoenix, Arizona

Postby aids » 2011.09.06 (22:13)

tl;dr >> Glitches tiles are a bitch to use.

This is pretty interesting, but I have no clue how to utilize it. Think you could make some examples? All that's just gibberish which says, "You'll need to playtest a hella long time."
Image

//--^.^--\\
\\.:.^.:.//

User avatar
Average Time to Take Breakfast in Equador
Posts: 640
Joined: 2008.09.27 (03:11)
NUMA Profile: http://nmaps.net/user/geti
MBTI Type: ENFJ
Contact:

Postby Geti » 2011.09.07 (14:29)

I made a map using these ages ago.

oh, 2 apparently
http://www.nmaps.net/70393
http://www.nmaps.net/70526

Back when I was a pretentious wanker or 14 or something.

I didn't know exactly how they worked though, just used the "playtest for ages" approach. You can do some cool launches out of them.

Cheers for the writeup, though I think you're wrong about how N handles maps - it's just SAT collision afaik. If this is just your way of visualising it then cool, but I don't think it's implemented in such a backwards way :P
spoiler

"I'd be happy for a lion if it hunted me down and ate me, but not so happy for it if it locked up me and my family, then forced us to breed so it may devour our offspring." - entwilight <3
How do you know that God didn't intend for humans to be the animals' caretakers? He might be appalled that He gave us these animals to use and we're fucking eating them. - Tsukatu
4th - DDA Speedrunning Contest.
One Hundred Percent Vegetarian

deviantArt Profile - 1BarDesign
God knows if i'm back.

User avatar
The Dreamster Teamster
Posts: 84
Joined: 2010.06.28 (22:53)
NUMA Profile: http://nmaps.net/user/atomizer
Steam: https://steamcommunity.com/id/_atomizer
MBTI Type: INTP
Contact:

Postby atomizer » 2011.09.07 (15:05)

@Aids it was never intented to be a "howto". just me messing around with the engine and <canvas>.

@Geti of course there is no such thing as these silly collision maps in the game itself, I just couldn't come up with better way to visualise many different situations in a single picture. Each colored pixel represents direction and length of the resulting "push" provided by the CollideCirclevsTileMap function, which is indeed SAT-based.

User avatar
Demon Fisherman
Posts: 1246
Joined: 2008.10.01 (23:37)
NUMA Profile: http://nmaps.net/squibbles
MBTI Type: ENFP
Location: Canberra

Postby squibbles » 2011.09.09 (11:27)

I approve fully.
spoiler

Nmaps.net

Tsukatu wrote:I don't know what it is, squibbles, but my brain keeps inserting "black" into random parts of your posts these days.
I totally just read that as, "I'd hate to be the only black guy stuck using v1.4."
[/ispoiler]


Who is online

Users browsing this forum: No registered users and 4 guests