3
\$\begingroup\$

Ok so I'm trying to make a nice little RPG game in Java & Slick2D engine, the tiles are 16x16, so the collision array is also 16x16, how ever my character sprite is 16x20

What would be the best method of moving the character in relation to a 16x16 grid, also checking for collision?

\$\endgroup\$
  • \$\begingroup\$ How do you define "best method?" \$\endgroup\$ – Nicol Bolas Apr 28 '12 at 0:29
  • \$\begingroup\$ It depends on movement, does your character move by tiles? if sou then you probably want him to occupy just one tile (that tile that he has feet on, because why would you want to collide his head with something on ground) If he moves by pixels, then you probably want smaller rectangle then 16x16, because it would be stresful to go through narrow passages. (i noticed that you are using slick2d so if this questin is something engine specific, this probably is not an answer) \$\endgroup\$ – Kikaimaru Apr 28 '12 at 0:41
5
\$\begingroup\$

What you should do is keep characters separate from tiles, but in terms of placement, just have a position at like feet/bottom of the sprite and align that with the bottom edge of the tile. And for collision checking, you could use a rectangle intersection check based on maybe the bottom quarter of the player or the size of the tile even. Experiment

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.