Jump to content
  • Advertisement
Sign in to follow this  
_WeirdCat_

position on grid

This topic is 1020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the image shows everything i have black square which is a section, and i have a red square which is a cell now if i have a cell in x,y how do i find in which section it is?

 

square.png

 

as you can see each section has 4 cells (2 in x direction 2 in y direction) also sections have the same coordinate system which is x,y (so section where blue cell is is 1,1)

 

ther eare 8 cells in one direction like 4 sections in the same direction, they are always the same (for x and y directions) additionally they are always power of 2 that means ther ecan be lets say 64 cells but only 2 section or 128 cells and 64 sections etc.

Edited by WiredCat

Share this post


Link to post
Share on other sites
Advertisement

i made exactly the same equations before i posted here, then i saw that when casting cell_x and cels_per_section_x i will end up with 2.0 / 2.0 which can be not 1 due to floatpoint inaccuracy, but after i saw your code (and checked that int(7) / int(8)  = 0 in http://www.gamedev.net/topic/676402-how-do-i-use-printf-to-display-an-int/ ) then your code makes perfect sense, thanks

Edited by WiredCat

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!