Kaif Kutchwala 201267448 ELEC2645 Project

Dependencies:   mbed

Committer:
KaifK
Date:
Sat May 16 13:10:01 2020 +0000
Revision:
4:08a0ff6668df
Parent:
3:f86c1cf90d0d
Child:
8:5ede90f99a27
rebuilding lost code initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KaifK 2:21973e665a32 1 #ifndef BALL_H
KaifK 2:21973e665a32 2 #define BALL_H
KaifK 2:21973e665a32 3
KaifK 2:21973e665a32 4 #include <cmath>
KaifK 2:21973e665a32 5 #include "mbed.h"
KaifK 2:21973e665a32 6 #include "Gamepad.h"
KaifK 2:21973e665a32 7 #include "N5110.h"
KaifK 2:21973e665a32 8
KaifK 2:21973e665a32 9 #define BALL_INIT_X 35
KaifK 2:21973e665a32 10 #define BALL_INIT_Y 43
KaifK 2:21973e665a32 11 class Ball {
KaifK 2:21973e665a32 12 public:
KaifK 2:21973e665a32 13 /** Constructor */
KaifK 2:21973e665a32 14 Ball();
KaifK 2:21973e665a32 15
KaifK 2:21973e665a32 16 /** Destructor */
KaifK 2:21973e665a32 17 ~Ball();
KaifK 2:21973e665a32 18
KaifK 2:21973e665a32 19 /** @brief Places ball on the screen in initial position (35,43) */
KaifK 2:21973e665a32 20 void init(N5110 &lcd);
KaifK 2:21973e665a32 21
KaifK 3:f86c1cf90d0d 22 /** @brief Places ball at position (x,y) required for animation function
KaifK 2:21973e665a32 23 * @param x @details x coordinate of required position
KaifK 2:21973e665a32 24 * @param y @details y coordinate of required position
KaifK 2:21973e665a32 25 */
KaifK 3:f86c1cf90d0d 26 void setLocation(int x, int y,N5110 &lcd);
KaifK 2:21973e665a32 27
KaifK 4:08a0ff6668df 28 /** @brief Plays animation of ball being shot based on user input.
KaifK 4:08a0ff6668df 29 * @param user_input_x @details x coordinate of final position
KaifK 4:08a0ff6668df 30 * @param user_input_y @details y coordinate of final position
KaifK 4:08a0ff6668df 31 */
KaifK 3:f86c1cf90d0d 32 void playShot(int user_input_x, int user_input_y,N5110 &lcd);
KaifK 2:21973e665a32 33
KaifK 4:08a0ff6668df 34 /** @brief Plays animation of ball bouncing.
KaifK 4:08a0ff6668df 35 * @param x_pos @details horizontal position of ball bouncing on screen
KaifK 4:08a0ff6668df 36 * @param y_pos @details initial vertical position of ball bouncing on screen
KaifK 4:08a0ff6668df 37 * @param height @details height of bounce
KaifK 4:08a0ff6668df 38 * @param status @details toggles bouncing animation
KaifK 4:08a0ff6668df 39 */
KaifK 4:08a0ff6668df 40 void bounceBall (int x_pos, int y_pos, int height, int status, N5110 &lcd);
KaifK 4:08a0ff6668df 41
KaifK 4:08a0ff6668df 42 void set_status(bool status);
KaifK 4:08a0ff6668df 43 int get_status();
KaifK 4:08a0ff6668df 44
KaifK 2:21973e665a32 45 private:
KaifK 2:21973e665a32 46
KaifK 2:21973e665a32 47 int _user_input_x;
KaifK 2:21973e665a32 48 int _user_input_y;
KaifK 2:21973e665a32 49 int _ball_x;
KaifK 2:21973e665a32 50 int _ball_y;
KaifK 4:08a0ff6668df 51 int _height;
KaifK 4:08a0ff6668df 52 bool _status;
KaifK 2:21973e665a32 53 };
KaifK 3:f86c1cf90d0d 54
KaifK 3:f86c1cf90d0d 55
KaifK 3:f86c1cf90d0d 56
KaifK 2:21973e665a32 57
KaifK 2:21973e665a32 58 #endif
KaifK 2:21973e665a32 59