How To

Sprite collision with a cell

0

Tran Duy Hoang 2019-09-29 05:57

I’ve seen a lot of topics but i still don’t understand.Can any one help me ?


was8bit 2019-09-30 03:46 (Edited)

The hardest part is that sprites and cells use different grid systems..

Sprites go by PIXELS, where cells go by CELLS

SO, CELL 1,1,12 places character 12 in cell location 1,1
SPRITE 0,1,1,12 places sprite 0 at pixel 1,1

BUT, cell location 1,1 actually occupies pixel locations 8,8 by 15,15

This makes the math abit "tricky"... especially if you want to allow the sprite to move with pixel precison..

A workaround is to control sprite movement from empty cell to empty cell...

... if you need more help, just let me know if you want "FREE MOVEMENT" or "CELL TO CELL" as they will require different approaches...

Sprite x,y refers to its upper left corner


was8bit 2019-09-30 04:20

I made a little demonstration program...

https://lowresnx.inutilis.com/topic.php?id=676


Tran Duy Hoang 2019-09-30 10:13

Thanks a lots !


was8bit 2019-09-30 11:25

Glad i could help :)

Just remember that the sprite x,y is its upper left corner, and you should be fine working out the math :)


Log in to reply.