-
Notifications
You must be signed in to change notification settings - Fork 8
/
Collideable.hpp
38 lines (32 loc) · 925 Bytes
/
Collideable.hpp
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
/*
* Snake game program using the SDL library
*
* @author J. Alvarez
*/
#include "SDL2/SDL.h"
#include "Screen.hpp"
#include "Drawable.hpp"
#ifndef COLLIDEABLE_HPP
#define COLLIDEABLE_HPP
namespace SnakeGame {
/**
* This class represents an object that can collide with others
* The most basic collision is implemented: objects have same size, so if they
* are in the same position a collision is assumed
*/
struct Collideable: Drawable {
/**
* Creates an Collideable instance with a position
* @param x X position of this object
* @param y Y position of this object
*/
Collideable(int x, int y);
/**
* Validates whether there is a collision between this object and another
* @param other The other object to check whether collision occurs
* @return boolean indicating whether collision occurs
*/
bool collidesWith(Collideable & other);
};
} // namespace SnakeGame
#endif // COLLIDEABLE_HPP