![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
N5110
PongEngine/PongEngine.h@0:90b7f20b3a8d, 2020-04-28 (annotated)
- Committer:
- aileen
- Date:
- Tue Apr 28 01:39:30 2020 +0000
- Revision:
- 0:90b7f20b3a8d
N5110
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aileen | 0:90b7f20b3a8d | 1 | #ifndef PONGENGINE_H |
aileen | 0:90b7f20b3a8d | 2 | #define PONGENGINE_H |
aileen | 0:90b7f20b3a8d | 3 | |
aileen | 0:90b7f20b3a8d | 4 | #include "mbed.h" |
aileen | 0:90b7f20b3a8d | 5 | #include "N5110.h" |
aileen | 0:90b7f20b3a8d | 6 | #include "Gamepad.h" |
aileen | 0:90b7f20b3a8d | 7 | #include "Ball.h" |
aileen | 0:90b7f20b3a8d | 8 | #include "Paddle.h" |
aileen | 0:90b7f20b3a8d | 9 | |
aileen | 0:90b7f20b3a8d | 10 | // gap from edge of screen |
aileen | 0:90b7f20b3a8d | 11 | #define GAP 2 |
aileen | 0:90b7f20b3a8d | 12 | |
aileen | 0:90b7f20b3a8d | 13 | class PongEngine |
aileen | 0:90b7f20b3a8d | 14 | { |
aileen | 0:90b7f20b3a8d | 15 | |
aileen | 0:90b7f20b3a8d | 16 | public: |
aileen | 0:90b7f20b3a8d | 17 | PongEngine(); |
aileen | 0:90b7f20b3a8d | 18 | ~PongEngine(); |
aileen | 0:90b7f20b3a8d | 19 | |
aileen | 0:90b7f20b3a8d | 20 | void init(int paddle_width,int paddle_height,int ball_size,int speed); |
aileen | 0:90b7f20b3a8d | 21 | void read_input(Gamepad &pad); |
aileen | 0:90b7f20b3a8d | 22 | void update(Gamepad &pad); |
aileen | 0:90b7f20b3a8d | 23 | void draw(N5110 &lcd); |
aileen | 0:90b7f20b3a8d | 24 | |
aileen | 0:90b7f20b3a8d | 25 | private: |
aileen | 0:90b7f20b3a8d | 26 | |
aileen | 0:90b7f20b3a8d | 27 | void check_wall_collision(Gamepad &pad); |
aileen | 0:90b7f20b3a8d | 28 | void check_paddle_collisions(Gamepad &pad); |
aileen | 0:90b7f20b3a8d | 29 | void check_goal(Gamepad &pad); |
aileen | 0:90b7f20b3a8d | 30 | void print_scores(N5110 &lcd); |
aileen | 0:90b7f20b3a8d | 31 | |
aileen | 0:90b7f20b3a8d | 32 | Paddle _p1; |
aileen | 0:90b7f20b3a8d | 33 | Paddle _p2; |
aileen | 0:90b7f20b3a8d | 34 | |
aileen | 0:90b7f20b3a8d | 35 | int _paddle_width; |
aileen | 0:90b7f20b3a8d | 36 | int _paddle_height; |
aileen | 0:90b7f20b3a8d | 37 | int _ball_size; |
aileen | 0:90b7f20b3a8d | 38 | int _speed; |
aileen | 0:90b7f20b3a8d | 39 | |
aileen | 0:90b7f20b3a8d | 40 | // x positions of the paddles |
aileen | 0:90b7f20b3a8d | 41 | int _p1x; |
aileen | 0:90b7f20b3a8d | 42 | int _p2x; |
aileen | 0:90b7f20b3a8d | 43 | |
aileen | 0:90b7f20b3a8d | 44 | Ball _ball; |
aileen | 0:90b7f20b3a8d | 45 | |
aileen | 0:90b7f20b3a8d | 46 | Direction _d; |
aileen | 0:90b7f20b3a8d | 47 | float _mag; |
aileen | 0:90b7f20b3a8d | 48 | |
aileen | 0:90b7f20b3a8d | 49 | }; |
aileen | 0:90b7f20b3a8d | 50 | |
aileen | 0:90b7f20b3a8d | 51 | #endif |