Object respawning: Difference between revisions

Jump to navigation Jump to search
m
imported>Leoetlino
imported>Leoetlino
Line 21: Line 21:
where the player column and row values are calculated as follows:
where the player column and row values are calculated as follows:
<source lang="c++">
<source lang="c++">
  int col = std::clamp(((signed int)x + 5000) / 1000, 0, 9);
int col = std::clamp(((signed int)x + 5000) / 1000, 0, 9);
  int row = std::clamp(((signed int)z + 4000) / 1000, 0, 7);
int row = std::clamp(((signed int)z + 4000) / 1000, 0, 7);
  if ( (col + 0.5) * 1000.0 + -5000.0 >= x ) {
if ( (col + 0.5) * 1000.0 + -5000.0 >= x ) {
    *col1 = col - 1;
  *col1 = col - 1;
    *col2 = col;
  *col2 = col;
  } else {
} else {
    *col1 = col;
  *col1 = col;
    *col2 = col + 1;
  *col2 = col + 1;
  }
}
  if ( (row + 0.5) * 1000.0 + -4000.0 >= z ) {
if ( (row + 0.5) * 1000.0 + -4000.0 >= z ) {
    *row1 = row - 1;
  *row1 = row - 1;
    *row2 = row;
  *row2 = row;
  } else {
} else {
    *row1 = row;
  *row1 = row;
    *row2 = row + 1;
  *row2 = row + 1;
  }
}
</source>
</source>


Anonymous user

Navigation menu