| 
									
										
										
										
											2022-07-28 15:18:24 -05:00
										 |  |  | // Snake.h
 | 
					
						
							| 
									
										
										
										
											2022-07-25 15:40:45 -05:00
										 |  |  | #ifndef SNAKE_H
 | 
					
						
							|  |  |  | #define SNAKE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-26 18:18:45 -06:00
										 |  |  | #include <deque>
 | 
					
						
							|  |  |  | #include <SFML\Graphics.hpp>
 | 
					
						
							|  |  |  | #include "SnakeFood.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-25 15:40:45 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Snake | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-03-13 08:24:56 -05:00
										 |  |  |     bool gameFinished = false; | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     Snake(void); | 
					
						
							| 
									
										
										
										
											2022-07-26 19:03:55 -05:00
										 |  |  |     void DisplaySnake(sf::RenderWindow& window); | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     sf::RectangleShape GetSnakeHead(void); | 
					
						
							|  |  |  |     sf::Vector2f GetSnakeHeadPosition(void); | 
					
						
							| 
									
										
										
										
											2023-03-12 08:50:50 -05:00
										 |  |  |     bool IsTouchingObject(sf::RectangleShape object); | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     void MoveSnake(SnakeFood* playerFood); | 
					
						
							| 
									
										
										
										
											2023-03-13 08:24:56 -05:00
										 |  |  |     void Reset(void); | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     void UpdateDirection(int newDirection); | 
					
						
							| 
									
										
										
										
											2023-03-12 08:50:50 -05:00
										 |  |  | protected: | 
					
						
							|  |  |  |     ; | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     std::deque<sf::RectangleShape> snakeBody; | 
					
						
							| 
									
										
										
										
											2023-03-13 08:24:56 -05:00
										 |  |  |     sf::Vector2f bodyPartSize; | 
					
						
							| 
									
										
										
										
											2023-03-12 08:50:50 -05:00
										 |  |  |     int snakeDirection = 0; | 
					
						
							| 
									
										
										
										
											2023-03-13 08:24:56 -05:00
										 |  |  |     void AddBodyPart(sf::RectangleShape newBodyPart); | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     sf::Vector2f CalculateNewPosition(sf::Vector2f position); | 
					
						
							|  |  |  |     bool CheckBoundaries(void); | 
					
						
							| 
									
										
										
										
											2023-03-13 08:24:56 -05:00
										 |  |  |     void CreateHead(void); | 
					
						
							| 
									
										
										
										
											2023-03-12 21:57:46 -05:00
										 |  |  |     bool IsSelfCollision(sf::RectangleShape testRectangle); | 
					
						
							| 
									
										
										
										
											2022-07-25 15:40:45 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |