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.

34 lines
1.1 KiB

  1. #pragma once
  2. #include <list>
  3. #include "Point.h" //the library we need to implement the snake
  4. #include "Snack.h"
  5. #define BODY 'o'
  6. class Snake{
  7. private:
  8. std::list<Point> snake; //the snake will be implemented as a list of points where the first element is the head
  9. graphics_input direction;
  10. void updateHead(void);
  11. void printSnake(void);
  12. public:
  13. Snake(int headY = LINES/2, int headX = COLS/2); //default constructor
  14. ~Snake(); //destructor
  15. //basic move functions
  16. void moveUp(void);
  17. void moveDown(void);
  18. void moveLeft(void);
  19. void moveRight(void);
  20. bool isBitten(void); //function to check if the snake bit its self
  21. bool hasBitSnack(int snackY, int snackX);//checks if the snake has bitten a snack
  22. bool hasCrashedWall(void); // method to check if the snake crashed the walls
  23. int getSize(void); //get the current length
  24. void incSize(void); //function to increase the length
  25. void move(void); //function to refresh the image of the snake
  26. };