-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHitCheck.cpp
More file actions
39 lines (35 loc) · 833 Bytes
/
Copy pathHitCheck.cpp
File metadata and controls
39 lines (35 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include "HitCheck.h"
#include "snake.h"
#include "food.h"
#include <cmath>
bool DidItHitWall(const Snake& snake)
{
sf::Vector2i head = snake.body.back();
// If head is outside the valid grid [0..(GRID_SIZE-1)],
// then it must have hit a wall
if (head.x < 0 || head.x >= GRID_SIZE || head.y < 0 || head.y >= GRID_SIZE)
{
return true;
}
return false;
}
bool AreYaWinningSon(const Snake& snake)
{
if (snake.length>=pow(GRID_SIZE,2)-4)
{
return true;
}
return false;
}
bool DidItEat(const Snake& snake)
{
sf::Vector2i head = snake.body.back();
if (head.x==appleXY.x && head.y==appleXY.y)
{
return true;
}
return false;
}