Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by PeterRobinson

Hi,

I'm having a bit of a tough time trying to add custom collision map tiles to my game. I'm pretty sure I've found the right place but I'm just not entirely sure how to go about it.

The code I'm working with is in the file: lib\impact\collision-map.js

ig.CollisionMap.defaultTileDef = {	
	/* 15 NE */	 5: [0,1, 1,M, SOLID],  6: [0,M, 1,N, SOLID],  7: [0,N, 1,0, SOLID],
	/* 22 NE */	 3: [0,1, 1,H, SOLID],  4: [0,H, 1,0, SOLID],
	/* 45 NE */  2: [0,1, 1,0, SOLID],
	/* 67 NE */ 10: [H,1, 1,0, SOLID], 21: [0,1, H,0, SOLID],
	/* 75 NE */ 32: [M,1, 1,0, SOLID], 43: [N,1, M,0, SOLID], 54: [0,1, N,0, SOLID],

1 decade ago by PeterRobinson

I tried adding another line. Something like:

/* Go W  */ 45: [0,1, 0,0, NON_SOLID],

but I don't really understand the structure of the tile definition.

What do the /* 15 NE / and / 22 NE */ mean?

How can you specify the exact coordinates of the solid part of a tile with just 1 and 0?

Why is there no definition for a collision tile 0 or collision tile 1?

If anyone could point me in the right direction it'd be greatly appreciated!

1 decade ago by Joncom

I believe you're looking at sloped tile definitions, where 15 NE can be interpreted as 15 degrees in the direction of North East.

What sort of "custom collision map tile" are you looking to create?

1 decade ago by PixelPicoSean

@Joncom, is it possible to add curve edge tiles into the definition (as in the famous N serials)? I've read the code of impact++ which does extend tile shapes but those newly added are also triangles.
There's a physics engine port from N included in Phaser, but I still hope not to replace the whole physics part with that.

1 decade ago by Joncom

Yes, I'm sure it's possible. However, the easiest solution might be to use a more powerful physics engine, such as Box2D. Upgrading the physics engine in ImpactJS is pretty easy, especially if you use a plugin like this one.
Page 1 of 1
« first « previous next › last »