-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.h
45 lines (34 loc) · 831 Bytes
/
Point.h
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
40
41
42
43
44
45
//
// Created by hars on 23/07/22.
//
#ifndef CANDYCRUSH_POINT_H
#define CANDYCRUSH_POINT_H
#include <vector>
#include <iostream>
#include "Constants.h"
//Point class to wrap any {x,y} pair of type T (T is numerical).
template<typename T>
class Point{
public:
T x;
T y;
Point(T x, T y) : x(x), y(y) {
}
T xDistanceTo(Point c2){
return c2.x-x;
}
T yDistanceTo(Point c2){
return c2.y-y;
}
Point() = default;
};
//The Pxl class is strictly used to refer to pixel coordinates of the fltk window.
class Pxl : public Point<float>{
using Point<float>::Point;
};
//The coord class is strictly used to refer to the boardCell indices
// ie: A Coord{1,2} refers to boardCells[1][2]
class Coord: public Point<int> {
using Point<int>::Point;
};
#endif //CANDYCRUSH_POINT_H