-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPong.hpp
More file actions
103 lines (69 loc) · 1.58 KB
/
Pong.hpp
File metadata and controls
103 lines (69 loc) · 1.58 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Pong.hpp
*
* Created on: Jan 28, 2016
* Author: Matteo Rotundo
*/
#ifndef PONG_HPP_
#define PONG_HPP_
/* Starting position for the Vaus */
#define Pad_yL 11
#define Pad_yR 17
#define Pad1X 1
#define Pad2X 30
/* Rows&Columns for the Matrix */
#define RMATRIX 32
#define CMATRIX 32
#define NOTEST
extern unsigned char t_ball;
extern unsigned char t_pad1;
extern unsigned char t_pad2;
// Constants and library for TESTING
#ifdef TEST
#include "Test/MockMatrix.hpp" // Test library
#define BLUE 0, 0, 7
#define BLACK 0, 0, 0
#endif
// Libraries for the application
#ifdef NOTEST
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#endif
typedef enum DirectionPad{LEFT, RIGHT} DirectionPad;
typedef enum DirectionBall{NL, N, NR, SL, S, SR} DirectionBall;
class Pad {
public:
unsigned char lastL, lastR; // y coordinates
unsigned char x; // coordinate x
void movePad(DirectionPad);
Pad(int coordx);
};
class Ball {
public:
unsigned char x, y;
DirectionBall dirB;
Ball();
};
class MapGame {
#ifdef TEST
public:
RGBmatrixPanel matrix;
#endif
public:
Pad pad1 = Pad(1);
Pad pad2 = Pad(30);
Ball ball;
void checkDirBall();
void invertDirBall();
void movePad1(DirectionPad dirV);
void movePad2(DirectionPad dirV);
void moveBall();
void shotShore();
bool checkImpactPad1(int x, int y);
bool checkImpactPad2(int x, int y);
void modBallDirImpact(int x, int y);
void modBallDirImpact2(int x, int y);
bool checkImpactWall(int x, int y);
void displayVaus();
};
#endif /* PONG_HPP_ */