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 EralpB

Hello, what would be best way to implement a circular entity?

Entity vs entity is easier to implement but entity vs tiled collision map can be a little bit more tiresome.

The reason I am asking this is I am new to this great engine and I would like to learn the best way in terms of keeping the code as clean as possible.

{
    collision: { x: false, y: false, slope: false },
    pos: { x: 0, y: 0 }, // Resulting object position
    tile: { x: 0, y: 0 } // Tile for the collision
}

This is the trace result, so can I get world coordinates + tile size using this information? Or should I hard-code my tile size etc. to make this useful to use for collision detection.

Thanks.

1 decade ago by Joncom

Interesting question!

So far as I know, Impact only handles rectangle shaped collision boxes.

I'd be interested to hear if anyone has done what the OP is trying to do...

1 decade ago by EralpB

I think "Tile for the collision" should be changed to "Tile type for the collision". Because I found out that it returns the type :)

I am currently overriding handleMovementTrace and casting 20 rays from the player with the length player.size.x/2 (360/20= one ray per 18 degrees) if none of them hits I ignore the collision and run the code

       this.pos.x += this.vel.x * ig.system.tick;
       this.pos.y += this.vel.y * ig.system.tick;

if any of them hits I just end the function. Constant 20 can be changed ofc its just a matter of approximation.

I am not sure about the performance of the ig.game.collisionMap.trace function but I'll let you know if this adds an overhead.
Page 1 of 1
« first « previous next › last »