Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- #include <conio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <ctime>
- #include <list>
- #include "config.hpp"
- enum SnakeCellType {
- head, body, tail
- };
- struct SnakeCell {
- SnakeCellType cellType;
- unsigned char positionX;
- unsigned char positionY;
- SnakeCell(SnakeCellType initCellType, unsigned char initPosX, unsigned char initPosY):
- cellType(initCellType), positionX(initPosX), positionY(initPosY) {}
- SnakeCell() {}
- };
- class Snake {
- private:
- std::list<SnakeCell> _snakeCell;
- std::list<SnakeCell>::iterator itHead;
- std::list<SnakeCell>::iterator itTail;
- SnakeCell _preCell;
- Snake();
- void CutTail();
- void UpdateLimbs();
- void UpdateTail();
- void UpdateHead();
- public:
- Snake(unsigned char initPosX, unsigned char initPosY);
- void MoveLeft();
- void MoveRight();
- void MoveUp();
- void MoveDown();
- void MoveByKeyPressed(ControlKeyCodes keyPressed);
- void GrowTo(unsigned char newPosX, unsigned char newPosY);
- void GrowLeft();
- void GrowRight();
- void GrowUp();
- void GrowDown();
- unsigned char GetHeadPosX();
- unsigned char GetHeadPosY();
- unsigned char GetTailPosX();
- unsigned char GetTailPosY();
- unsigned char GetTailPrePosX();
- unsigned char GetTailPrePosY();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement