ruby - having trouble setting up simple rectangular collisions in chipmunk -
recently i've been trying create i've wanted, never had skill , time - computer game. more precise, homage / clone of 1 of many of favourite games. start simple i've decided create classic 2d platform based on castlevania series.
being ruby programmer i've decided use gosu. decided don't want reinvent wheel i'm going use chipmunk.
after few days, i've ended having inexplicable collision detection problems. i've added boundary-box drawing functions see hell going on.
as can see, belmont collides blocks of walls he's not remotely close touching. since demo game included gosu gem works fine, there must wrong i'm doing, don't udnerstand how polygon shape
defined , added space. i'm pretty sure it's not draw it.
there's public repo game, can see how walls (brush < entity
) , player (player < entity
) defined , indeed have simple, rectangular polygon shape. walls not added space (they rogue), player is. i've tried debugging game , see body
position is, looked fine.
https://github.com/ellmo/castellvania
player falls down slowly, can control him / left / right arrows. tilde button (~
) shows boudning boxes , collision boxes supposed visible.
i need trying understand doing wrong.
i don't udnerstand how polygon shape defined , added space. i'm pretty sure it's not draw it.
that's it. shape coordinates added body position, not substracted it. in entity.boundaries
replace line
verts << cp::vec2.new(@shape.body.p.x - @shape[vert].x, @shape.body.p.y - @shape[vert].y)
with
verts << cp::vec2.new(@shape.body.p.x + @shape[vert].x, @shape.body.p.y + @shape[vert].y)
and correct picture. (drawing still broken, bounding boxes correct.
Comments
Post a Comment