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.

110 lines
2.4 KiB

  1. #include <iostream>
  2. #include <thread>
  3. #include <chrono>
  4. #include "components/Point.h"
  5. #include "components/Snack.h"
  6. #include "components/Snake.h"
  7. #include "input-output/Graphics.h"
  8. void mainL01() {
  9. Graphics::get().init("Learners Helper");
  10. Point p(10,10,'X');
  11. p.print();
  12. Graphics::get().refreshScreen();
  13. std::this_thread::sleep_for(std::chrono::seconds(10));
  14. Graphics::get().finalize();
  15. std::cout << "Helper QUIT" << std::endl;
  16. }
  17. void mainL02() {
  18. Graphics::get().init("Learners Helper 02");
  19. Point p(10,10);
  20. generateSnack(&p);
  21. Graphics::get().refreshScreen();
  22. std::this_thread::sleep_for(std::chrono::seconds(10));
  23. Graphics::get().finalize();
  24. std::cout << "Helper QUIT" << std::endl;
  25. }
  26. void mainL03() {
  27. Graphics::get().init("Learners Helper 03");
  28. Point p(10,10);
  29. for (uint32_t i = 0; i < 100; i++) {
  30. p.moveDown();
  31. Graphics::get().refreshScreen();
  32. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  33. p.moveRight();
  34. Graphics::get().refreshScreen();
  35. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  36. }
  37. /*
  38. while(...) {
  39. // TODO: play with this
  40. }
  41. */
  42. /*
  43. do {
  44. // TODO: play with this
  45. } while (...)
  46. */
  47. Graphics::get().finalize();
  48. std::cout << "Helper QUIT" << std::endl;
  49. }
  50. void mainL04() {
  51. Graphics::get().init("Learners Helper 04");
  52. Snake snake;
  53. for (uint32_t i = 0; i < 100; i++) {
  54. snake.moveDown();
  55. Graphics::get().refreshScreen();
  56. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  57. snake.moveRight();
  58. Graphics::get().refreshScreen();
  59. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  60. }
  61. Graphics::get().finalize();
  62. std::cout << "Helper QUIT" << std::endl;
  63. }
  64. void mainL06() {
  65. Graphics::get().init("Learners Helper 06");
  66. Snake snake;
  67. // TODO: Now the snake will eventually crash into the lower wall which we detect and then abort
  68. // TODO: Figure out how to test the bit-itself and bit-snack functions yourself
  69. while(true) {
  70. snake.moveDown();
  71. Graphics::get().refreshScreen();
  72. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  73. if (snake.hasCrashedWall()) break;
  74. }
  75. Graphics::get().finalize();
  76. std::cout << "Helper QUIT" << std::endl;
  77. }
  78. int main() {
  79. mainL06();
  80. return 0;
  81. }