This a Library that can be used to make ping pong the Nokia Lcd 5110.
Ball.h@0:ef8d5a4464a3, 2016-05-04 (annotated)
- Committer:
- el14jpps
- Date:
- Wed May 04 23:22:04 2016 +0000
- Revision:
- 0:ef8d5a4464a3
Ping Pong library by Jefferson Sanchez
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el14jpps | 0:ef8d5a4464a3 | 1 | /** |
el14jpps | 0:ef8d5a4464a3 | 2 | @file Ball.h |
el14jpps | 0:ef8d5a4464a3 | 3 | @brief Header file containing functions for the ball. |
el14jpps | 0:ef8d5a4464a3 | 4 | |
el14jpps | 0:ef8d5a4464a3 | 5 | */ |
el14jpps | 0:ef8d5a4464a3 | 6 | |
el14jpps | 0:ef8d5a4464a3 | 7 | #ifndef BALL_H |
el14jpps | 0:ef8d5a4464a3 | 8 | #define PADDLE_H |
el14jpps | 0:ef8d5a4464a3 | 9 | |
el14jpps | 0:ef8d5a4464a3 | 10 | #include "mbed.h" |
el14jpps | 0:ef8d5a4464a3 | 11 | #include "N5110.h" |
el14jpps | 0:ef8d5a4464a3 | 12 | |
el14jpps | 0:ef8d5a4464a3 | 13 | /** |
el14jpps | 0:ef8d5a4464a3 | 14 | @brief This library has been made to allow the ball to update, check its position. etc This will make the coding later on in the main file a bit easier to manipulate. |
el14jpps | 0:ef8d5a4464a3 | 15 | @brief Revision 1.0 |
el14jpps | 0:ef8d5a4464a3 | 16 | @author Jefferson Sanchez |
el14jpps | 0:ef8d5a4464a3 | 17 | @date April 2016 |
el14jpps | 0:ef8d5a4464a3 | 18 | **/ |
el14jpps | 0:ef8d5a4464a3 | 19 | |
el14jpps | 0:ef8d5a4464a3 | 20 | class ball |
el14jpps | 0:ef8d5a4464a3 | 21 | { |
el14jpps | 0:ef8d5a4464a3 | 22 | /** Ball will give me the integers for x1,y1,xi position, y1 position . |
el14jpps | 0:ef8d5a4464a3 | 23 | */ |
el14jpps | 0:ef8d5a4464a3 | 24 | int x, y; |
el14jpps | 0:ef8d5a4464a3 | 25 | int x_Pos_state, y_Pos_state; |
el14jpps | 0:ef8d5a4464a3 | 26 | public: |
el14jpps | 0:ef8d5a4464a3 | 27 | /** Ball will give me the integers for x1,y1,x1 position, y1 position . |
el14jpps | 0:ef8d5a4464a3 | 28 | * @param pin connected to PTB3 in a Digital Input |
el14jpps | 0:ef8d5a4464a3 | 29 | * @param Pin Connected to PTB2 in a Digital Input |
el14jpps | 0:ef8d5a4464a3 | 30 | * @param Pins connected to +5v and GND to be able to obtain an integer value. |
el14jpps | 0:ef8d5a4464a3 | 31 | */ |
el14jpps | 0:ef8d5a4464a3 | 32 | ball(int x1, int y1, int x1_Pos_state, int y1_Pos_state) : x(x1), y(y1), x_Pos_state(x1_Pos_state), y_Pos_state(y1_Pos_state) {} |
el14jpps | 0:ef8d5a4464a3 | 33 | |
el14jpps | 0:ef8d5a4464a3 | 34 | /** Switches a pixel on in a particular coordinate in the X axis. |
el14jpps | 0:ef8d5a4464a3 | 35 | * |
el14jpps | 0:ef8d5a4464a3 | 36 | * ball.setX(41); |
el14jpps | 0:ef8d5a4464a3 | 37 | */ |
el14jpps | 0:ef8d5a4464a3 | 38 | void setX(int value); |
el14jpps | 0:ef8d5a4464a3 | 39 | /** Switches a pixel on in a particular coordinate in the Y axis. |
el14jpps | 0:ef8d5a4464a3 | 40 | * |
el14jpps | 0:ef8d5a4464a3 | 41 | * ball.setY(23); |
el14jpps | 0:ef8d5a4464a3 | 42 | * |
el14jpps | 0:ef8d5a4464a3 | 43 | */ |
el14jpps | 0:ef8d5a4464a3 | 44 | void setY(int value); |
el14jpps | 0:ef8d5a4464a3 | 45 | /** Switches a pixel on in a particular coordinate in the X axis. |
el14jpps | 0:ef8d5a4464a3 | 46 | * |
el14jpps | 0:ef8d5a4464a3 | 47 | * ball.setY(23); |
el14jpps | 0:ef8d5a4464a3 | 48 | * |
el14jpps | 0:ef8d5a4464a3 | 49 | */ |
el14jpps | 0:ef8d5a4464a3 | 50 | int lookforX(); |
el14jpps | 0:ef8d5a4464a3 | 51 | /** |
el14jpps | 0:ef8d5a4464a3 | 52 | *@param Allows me to check to see what pixels are on in the Y coordinate. |
el14jpps | 0:ef8d5a4464a3 | 53 | @returns y value. |
el14jpps | 0:ef8d5a4464a3 | 54 | */ |
el14jpps | 0:ef8d5a4464a3 | 55 | int lookforY(); |
el14jpps | 0:ef8d5a4464a3 | 56 | /** |
el14jpps | 0:ef8d5a4464a3 | 57 | *@param Checks the position state on the X coordinate. |
el14jpps | 0:ef8d5a4464a3 | 58 | *@returns x position state. |
el14jpps | 0:ef8d5a4464a3 | 59 | */ |
el14jpps | 0:ef8d5a4464a3 | 60 | int lookforPos_stateX(); |
el14jpps | 0:ef8d5a4464a3 | 61 | /** Checks the position state on the Y coordinate. |
el14jpps | 0:ef8d5a4464a3 | 62 | @returns y position state. |
el14jpps | 0:ef8d5a4464a3 | 63 | */ |
el14jpps | 0:ef8d5a4464a3 | 64 | int lookforPos_stateY(); |
el14jpps | 0:ef8d5a4464a3 | 65 | /** Checks the Collisions state on the X and Y coordinates. |
el14jpps | 0:ef8d5a4464a3 | 66 | */ |
el14jpps | 0:ef8d5a4464a3 | 67 | |
el14jpps | 0:ef8d5a4464a3 | 68 | void BallcollisionState(int xPos_state, int yPos_state); |
el14jpps | 0:ef8d5a4464a3 | 69 | /** Diameter of the ball. |
el14jpps | 0:ef8d5a4464a3 | 70 | */ |
el14jpps | 0:ef8d5a4464a3 | 71 | void dbal(N5110 &display); |
el14jpps | 0:ef8d5a4464a3 | 72 | /** States the clearing of pixels for the ball as it moves |
el14jpps | 0:ef8d5a4464a3 | 73 | */ |
el14jpps | 0:ef8d5a4464a3 | 74 | void clear_dbal(N5110 &display); |
el14jpps | 0:ef8d5a4464a3 | 75 | /** This is used to refresh the position of the ball. |
el14jpps | 0:ef8d5a4464a3 | 76 | */ |
el14jpps | 0:ef8d5a4464a3 | 77 | void Refresh_pos(); |
el14jpps | 0:ef8d5a4464a3 | 78 | |
el14jpps | 0:ef8d5a4464a3 | 79 | }; |
el14jpps | 0:ef8d5a4464a3 | 80 | |
el14jpps | 0:ef8d5a4464a3 | 81 | #endif |