spawn.cpp 585 B

12345678910111213141516171819
  1. #include "spawn.h"
  2. #define SAMPLER_X 19
  3. #define SAMPLER_Y 10
  4. #define WIDE_X w/SAMPLER_X
  5. #define WIDE_Y h/SAMPLER_Y
  6. #define WIDE_SUM WIDE_MAX+WIDE_MIN
  7. #define SAFE_ZONE 200
  8. void spawn( std::vector<SDL_Rect>* obs, Uint16 nb, Uint16 w, Uint16 h )
  9. {
  10. for ( Uint16 i(0); i < nb; i++)
  11. {
  12. obs->push_back( { SAFE_ZONE + rand()%(w-SAFE_ZONE-WIDE_X), // x
  13. rand()%(h-WIDE_Y), // y
  14. WIDE_X, // w
  15. WIDE_Y} ); // h
  16. }
  17. }