Final Submission. I have read and agreed with Statement of Academic Integrity.
Embed:
(wiki syntax)
Show/hide line numbers
Spaceship.h
00001 /** Spaceship Class 00002 * @brief It manages data relevant to spaceships in the game 00003 * @author Nicholas Wu 00004 * @date May, 2020 00005 */ 00006 #ifndef SPACESHIP_H 00007 #define SPACESHIP_H 00008 #include "mbed.h" 00009 00010 class Spaceship{ 00011 private: 00012 float v_x, v_y, acceleration, top_speed, turn_rate; 00013 int chamber, reload_timer; 00014 00015 // Below five: manage direction and velocity 00016 void turn_CW(); 00017 void turn_CCW(); 00018 void accelerate(); 00019 void deccelerate(); 00020 void update_position(); 00021 00022 /** Controls import parameters from main 00023 * @param x and y (float) from left joystick 00024 * @returns void but writes to bullets[][] 00025 */ 00026 void machine_gun(float x, float y); 00027 00028 void cannon(); 00029 void update_bullets(); 00030 00031 public: 00032 float orientation, bullet[5][4], pos_x, pos_y; 00033 int HP, gun_FX, explosion_FX; 00034 // gun_FX and explosion_FX manages sound 00035 00036 /** Constructor 00037 * @param pos_x and pos_y (float) are set to an arbitrary value 00038 */ 00039 Spaceship(){ 00040 pos_x = 100; 00041 pos_y = 100; 00042 } 00043 00044 /** Destructor 00045 * @param pos_x and pos_y (float) are set to an arbitrary value 00046 */ 00047 ~Spaceship(){ 00048 pos_x = 0; 00049 pos_y = 0; 00050 } 00051 00052 /** controls import from main 00053 * @param Y, A, X, B (bool) from buttons, 00054 * @param x and y (float) from left joystick. 00055 * interacts with private control functions 00056 */ 00057 void controls(bool player_ship_type, 00058 bool Y, bool A, bool X, 00059 bool B, float x, float y); 00060 00061 /** locally directs AI ship to designated target 00062 * @param target_x and target_y (float) for player's position 00063 * @param target_orientation for player's direction 00064 */ 00065 void AI_controls(float target_x, float target_y, 00066 float target_orientation); 00067 00068 /** used to set parameters relevent to gameplay 00069 * @param x, y and direction (float) concerns position 00070 * @param turn, acc and top (float) denotes turn rate, acceleration and top speed 00071 * @param health (int) sets maximum hitpoints 00072 */ 00073 void init_ship(float x, float y, float direction, 00074 float turn, float acc, float top, int health); 00075 00076 /** for rendering particles (bullets) of a specific ship 00077 * @param temp1, temp2 (int) represents a position on the map 00078 * @return 1 if the area contains a bullet 00079 */ 00080 bool check_bullets(int temp1, int temp2); 00081 00082 /** for discovering presence of a spaceship's bullets in an area 00083 * @param target_x, target_y (float) for centre position 00084 * @param radius (int) for target area radius 00085 * @return 1 on an effective hit 00086 */ 00087 bool check_hitbox(int target_x, int target_y, int radius); 00088 00089 /** public function used to call update_bullets and update_position 00090 */ 00091 void update(); 00092 }; 00093 00094 #endif
Generated on Tue Jul 12 2022 17:30:57 by
1.7.2