Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Ball/Ball.h@9:a81db6a703b7, 2019-04-21 (annotated)
- Committer:
- shahidsajid
- Date:
- Sun Apr 21 17:35:15 2019 +0000
- Revision:
- 9:a81db6a703b7
- Parent:
- 7:a1a6bff238c1
- Child:
- 10:6c6e09023942
fixed set_field bug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shahidsajid | 3:bd3465a70a5a | 1 | #ifndef BALL_H |
shahidsajid | 3:bd3465a70a5a | 2 | #define BALL_H |
shahidsajid | 3:bd3465a70a5a | 3 | |
shahidsajid | 3:bd3465a70a5a | 4 | #include "mbed.h" |
shahidsajid | 3:bd3465a70a5a | 5 | #include "N5110.h" |
shahidsajid | 3:bd3465a70a5a | 6 | #include "Gamepad.h" |
shahidsajid | 6:3e50f2cf4366 | 7 | #include "Bat.h" |
shahidsajid | 3:bd3465a70a5a | 8 | /** Ball Class |
shahidsajid | 3:bd3465a70a5a | 9 | @author Dr Craig A. Evans, University of Leeds |
shahidsajid | 3:bd3465a70a5a | 10 | @brief Controls the ball in the Pong game |
shahidsajid | 3:bd3465a70a5a | 11 | @date Febraury 2017 |
shahidsajid | 3:bd3465a70a5a | 12 | */ |
shahidsajid | 3:bd3465a70a5a | 13 | class Ball |
shahidsajid | 3:bd3465a70a5a | 14 | { |
shahidsajid | 3:bd3465a70a5a | 15 | |
shahidsajid | 3:bd3465a70a5a | 16 | public: |
shahidsajid | 3:bd3465a70a5a | 17 | Ball(); |
shahidsajid | 3:bd3465a70a5a | 18 | ~Ball(); |
shahidsajid | 3:bd3465a70a5a | 19 | void init(int size,int speed); |
shahidsajid | 3:bd3465a70a5a | 20 | void draw(N5110 &lcd); |
shahidsajid | 3:bd3465a70a5a | 21 | void update(); |
shahidsajid | 3:bd3465a70a5a | 22 | /// accessors and mutators |
shahidsajid | 3:bd3465a70a5a | 23 | void set_velocity(Vector2D v); |
shahidsajid | 3:bd3465a70a5a | 24 | Vector2D get_velocity(); |
shahidsajid | 3:bd3465a70a5a | 25 | Vector2D get_pos(); |
shahidsajid | 3:bd3465a70a5a | 26 | void set_pos(Vector2D p); |
shahidsajid | 7:a1a6bff238c1 | 27 | void start(N5110 &lcd,int checkHit, Direction dir); |
shahidsajid | 3:bd3465a70a5a | 28 | void get_direction(Gamepad &pad); |
shahidsajid | 3:bd3465a70a5a | 29 | void set_field(N5110 &lcd); |
shahidsajid | 7:a1a6bff238c1 | 30 | void update_ball(int checkHit, Direction dir); |
shahidsajid | 7:a1a6bff238c1 | 31 | int bowler_start(); |
shahidsajid | 9:a81db6a703b7 | 32 | void draw_field(N5110 &lcd); |
shahidsajid | 9:a81db6a703b7 | 33 | void reset(); |
shahidsajid | 3:bd3465a70a5a | 34 | |
shahidsajid | 3:bd3465a70a5a | 35 | private: |
shahidsajid | 4:55a0509c4874 | 36 | Gamepad pad; |
shahidsajid | 4:55a0509c4874 | 37 | struct Fielder{ |
shahidsajid | 4:55a0509c4874 | 38 | int x; |
shahidsajid | 4:55a0509c4874 | 39 | int y; |
shahidsajid | 4:55a0509c4874 | 40 | int position; |
shahidsajid | 4:55a0509c4874 | 41 | }; |
shahidsajid | 9:a81db6a703b7 | 42 | int fieldNumbers[10]; |
shahidsajid | 6:3e50f2cf4366 | 43 | Bat bat; |
shahidsajid | 6:3e50f2cf4366 | 44 | int ballHit; |
shahidsajid | 3:bd3465a70a5a | 45 | Vector2D _velocity; |
shahidsajid | 4:55a0509c4874 | 46 | Fielder field[5]; |
shahidsajid | 9:a81db6a703b7 | 47 | int direction_set; |
shahidsajid | 9:a81db6a703b7 | 48 | Direction ball_direction; |
shahidsajid | 3:bd3465a70a5a | 49 | Direction _d; |
shahidsajid | 6:3e50f2cf4366 | 50 | int bowled; |
shahidsajid | 4:55a0509c4874 | 51 | int d; |
shahidsajid | 3:bd3465a70a5a | 52 | int _size; |
shahidsajid | 3:bd3465a70a5a | 53 | int _x; |
shahidsajid | 3:bd3465a70a5a | 54 | int _y; |
shahidsajid | 7:a1a6bff238c1 | 55 | int _x1; |
shahidsajid | 7:a1a6bff238c1 | 56 | int _y1; |
shahidsajid | 3:bd3465a70a5a | 57 | }; |
shahidsajid | 3:bd3465a70a5a | 58 | #endif |