Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
How do you define "best method?" –  Nicol Bolas Apr 28 '12 at 0:29
    
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) –  Kikaimaru Apr 28 '12 at 0:41
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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