You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
490 B

  1. #include "Snack.h"
  2. #include <random>
  3. void generateSnack(Point* snack){
  4. std::random_device dev;
  5. static std::mt19937 prng(dev());
  6. static std::uniform_int_distribution<std::mt19937::result_type> distX(0, GAME_RIGHT_WALL_X);
  7. static std::uniform_int_distribution<std::mt19937::result_type> distY(0, GAME_BOTTOM_WALL_Y);
  8. const uint32_t x = distX(prng);
  9. const uint32_t y = distY(prng);
  10. snack->setImg(SNACK_CHAR);
  11. snack->setPoint(y, x);
  12. snack->print();
  13. }