Advertisement
Guest User

HQ sprite idx

a guest
Mar 12th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <iostream>
  4.  
  5. unsigned const bounds[] = {170, 350, 520, 720};
  6.  
  7. unsigned calc_HQ_sprite_idx(unsigned rating)
  8. {
  9.    auto const begin = std::begin(bounds);
  10.    auto const end = std::end(bounds);
  11.    auto const it = std::upper_bound(begin, end, rating);
  12.    unsigned const idx = it - begin;
  13.  
  14.    std::cout << "Rating: " << rating << " = sprite[" << idx << "]\n";
  15.    return idx;
  16. }
  17. int main()
  18. {
  19.    calc_HQ_sprite_idx(0);
  20.    calc_HQ_sprite_idx(1000);
  21.    calc_HQ_sprite_idx(500);
  22.    calc_HQ_sprite_idx(520);
  23.    return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement