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@18:a260ce8db9e7, 2019-04-27 (annotated)
- Committer:
- shahidsajid
- Date:
- Sat Apr 27 15:42:36 2019 +0000
- Revision:
- 18:a260ce8db9e7
- Parent:
- 15:81a3aaf52647
- Child:
- 20:9d21599fe350
Created no. of balls completed; created a target; printed the target and no. of balls onto the screen; Created displays for when game is won and game is lost
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 | Vector2D get_pos(); |
shahidsajid | 3:bd3465a70a5a | 22 | void set_pos(Vector2D p); |
shahidsajid | 13:924891519a95 | 23 | void reset(); |
shahidsajid | 10:6c6e09023942 | 24 | |
shahidsajid | 10:6c6e09023942 | 25 | /// accessors and mutators |
shahidsajid | 15:81a3aaf52647 | 26 | int ball_start(Gamepad &pad); |
shahidsajid | 3:bd3465a70a5a | 27 | void get_direction(Gamepad &pad); |
shahidsajid | 18:a260ce8db9e7 | 28 | int get_ball_count(); |
shahidsajid | 18:a260ce8db9e7 | 29 | void reset_ball_count(); |
shahidsajid | 10:6c6e09023942 | 30 | |
shahidsajid | 12:954da4f4e565 | 31 | //void update_ball(int checkHit, Direction dir); |
shahidsajid | 14:122eaa3b7a50 | 32 | int update_ball(int expected_x,int expected_y); |
shahidsajid | 15:81a3aaf52647 | 33 | int bowler_start(Gamepad &pad); |
shahidsajid | 18:a260ce8db9e7 | 34 | void increment_ball_count(); |
shahidsajid | 3:bd3465a70a5a | 35 | |
shahidsajid | 3:bd3465a70a5a | 36 | private: |
shahidsajid | 4:55a0509c4874 | 37 | Gamepad pad; |
shahidsajid | 4:55a0509c4874 | 38 | struct Fielder{ |
shahidsajid | 10:6c6e09023942 | 39 | Direction dir; |
shahidsajid | 4:55a0509c4874 | 40 | int x; |
shahidsajid | 4:55a0509c4874 | 41 | int y; |
shahidsajid | 4:55a0509c4874 | 42 | int position; |
shahidsajid | 4:55a0509c4874 | 43 | }; |
shahidsajid | 9:a81db6a703b7 | 44 | int fieldNumbers[10]; |
shahidsajid | 6:3e50f2cf4366 | 45 | Bat bat; |
shahidsajid | 6:3e50f2cf4366 | 46 | int ballHit; |
shahidsajid | 18:a260ce8db9e7 | 47 | int _ball_count; |
shahidsajid | 3:bd3465a70a5a | 48 | Vector2D _velocity; |
shahidsajid | 9:a81db6a703b7 | 49 | Direction ball_direction; |
shahidsajid | 3:bd3465a70a5a | 50 | Direction _d; |
shahidsajid | 6:3e50f2cf4366 | 51 | int bowled; |
shahidsajid | 15:81a3aaf52647 | 52 | int set_tone; |
shahidsajid | 4:55a0509c4874 | 53 | int d; |
shahidsajid | 3:bd3465a70a5a | 54 | int _size; |
shahidsajid | 3:bd3465a70a5a | 55 | int _x; |
shahidsajid | 3:bd3465a70a5a | 56 | int _y; |
shahidsajid | 7:a1a6bff238c1 | 57 | int _x1; |
shahidsajid | 7:a1a6bff238c1 | 58 | int _y1; |
shahidsajid | 3:bd3465a70a5a | 59 | }; |
shahidsajid | 3:bd3465a70a5a | 60 | #endif |