How To

Sprite collision with a cell


PranXter 2019-06-27 02:27

I try to use cell.c to detect a wall but it doesn’t work. Is there a better way of accomplishing this?

Timo 2019-06-27 06:18

It should work. Keep in mind that cell co-ordinates are different than pixel co-ordinates. A cell is 8x8 pixels. For example a sprite is at 100,50, then you have to check cell 12,6. (100/8),(50/8)

was8bit 2019-06-27 11:46 (Edited)

Yes, that is the “sticky wicket”...

SPRITE is place by pixel precision, and CELL is placed by its grid number based on each cell being 8x8 pixels in size...

ALSO of great importance is that the sprite’s x,y coordinate is locate at its upper left corner... so technically you are only checking it’s upper left corner... you need to consider all 4 corners... it’s lower right location for a 1x1cell sprite is its X+8, and it’s Y+8... 2x2 cell sprites have its lower right corner as its X+16 and it’s Y+16...

was8bit 2019-06-27 11:48

I recommend you check out TIMO’s game
Where he does this already, as well has built in scrolling. :)

PranXter 2019-06-27 15:21

Thanks for the help! I’m making good progress on my new NX game.

was8bit 2019-06-27 17:46

Cool, glad you’re here :D

PranXter 2019-06-27 18:06

I just finished the first level of my new puzzle game. I’m releasing it very soon.

was8bit 2019-06-27 19:20

Coool :)

Log in to reply.