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.
Weapons/Weapons.h@34:85ccc16f24d2, 2020-05-15 (annotated)
- Committer:
- evanso
- Date:
- Fri May 15 12:05:33 2020 +0000
- Revision:
- 34:85ccc16f24d2
- Parent:
- 31:6015e8ed859c
- Child:
- 82:3211b31e9421
Added when aliens collide with people, the people are abducted to the top of the screen. Then that alien tracks the spaceship and moves towards it rather than randomly moving.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| evanso | 17:25d79cca203a | 1 | #ifndef WEAPONS_H |
| evanso | 17:25d79cca203a | 2 | #define WEAPONS_H |
| evanso | 16:1ee3d3804557 | 3 | |
| evanso | 22:053c11a202e1 | 4 | // Included libraries ---------------------------------------------------------- |
| evanso | 16:1ee3d3804557 | 5 | #include "mbed.h" |
| evanso | 16:1ee3d3804557 | 6 | #include "N5110.h" |
| evanso | 16:1ee3d3804557 | 7 | #include "Gamepad.h" |
| evanso | 28:a5958497d5ce | 8 | #include "RandomMovement.h" |
| evanso | 16:1ee3d3804557 | 9 | |
| evanso | 16:1ee3d3804557 | 10 | /** Weapons class |
| evanso | 27:8bb2bd97c319 | 11 | * @brief Draws and moves weapons |
| evanso | 27:8bb2bd97c319 | 12 | * @author Benjamin Evans, University of Leeds |
| evanso | 27:8bb2bd97c319 | 13 | * @date April 2020 |
| evanso | 27:8bb2bd97c319 | 14 | */ |
| evanso | 31:6015e8ed859c | 15 | class Weapons: public RandomMovement { |
| evanso | 16:1ee3d3804557 | 16 | public: |
| evanso | 16:1ee3d3804557 | 17 | /** Constructor */ |
| evanso | 16:1ee3d3804557 | 18 | Weapons(); |
| evanso | 16:1ee3d3804557 | 19 | |
| evanso | 16:1ee3d3804557 | 20 | /** Destructor */ |
| evanso | 16:1ee3d3804557 | 21 | ~Weapons(); |
| evanso | 16:1ee3d3804557 | 22 | |
| evanso | 27:8bb2bd97c319 | 23 | /** Initalises Weapons |
| evanso | 28:a5958497d5ce | 24 | * @param sprite_pos @details vector 2D of sprite xy position |
| evanso | 28:a5958497d5ce | 25 | * @param sprite_direction @details sprite direction bool, |
| evanso | 27:8bb2bd97c319 | 26 | * true = E, false = W |
| evanso | 28:a5958497d5ce | 27 | * @param bullet_type @details true = spaceship, false = alien |
| evanso | 27:8bb2bd97c319 | 28 | */ |
| evanso | 28:a5958497d5ce | 29 | void init(Vector2D sprite_pos, bool sprite_direction,bool bullet_type); |
| evanso | 16:1ee3d3804557 | 30 | |
| evanso | 18:11068b98e261 | 31 | /** Draws the bullet and moves it in x direction each frame |
| evanso | 27:8bb2bd97c319 | 32 | * @param lcd @details N5110 object |
| evanso | 18:11068b98e261 | 33 | */ |
| evanso | 18:11068b98e261 | 34 | void draw_bullet(N5110 &lcd); |
| evanso | 28:a5958497d5ce | 35 | |
| evanso | 28:a5958497d5ce | 36 | /** Draws the aliens bullet and moves it in xy direction each frame |
| evanso | 28:a5958497d5ce | 37 | * @param lcd @details N5110 object |
| evanso | 28:a5958497d5ce | 38 | * @param d_ @details : Direction object of joystick |
| evanso | 28:a5958497d5ce | 39 | */ |
| evanso | 28:a5958497d5ce | 40 | void draw_alien_bullet(N5110 &lcd, Direction d_); |
| evanso | 31:6015e8ed859c | 41 | |
| evanso | 31:6015e8ed859c | 42 | /** Tuns lcd back light on and off |
| evanso | 31:6015e8ed859c | 43 | * @param lcd @details N5110 object |
| evanso | 31:6015e8ed859c | 44 | */ |
| evanso | 31:6015e8ed859c | 45 | void smart_bomb(N5110 &lcd); |
| evanso | 18:11068b98e261 | 46 | |
| evanso | 22:053c11a202e1 | 47 | // Accessors and mutators -------------------------------------------------- |
| evanso | 18:11068b98e261 | 48 | |
| evanso | 22:053c11a202e1 | 49 | /** sets the xy position of the bullet |
| evanso | 22:053c11a202e1 | 50 | * @param pos @details vector 2D of bullet xy position |
| evanso | 22:053c11a202e1 | 51 | */ |
| evanso | 22:053c11a202e1 | 52 | void set_pos_one(Vector2D pos); |
| evanso | 22:053c11a202e1 | 53 | |
| evanso | 20:febd920ec29e | 54 | /** Gets the bullet distance counter |
| evanso | 27:8bb2bd97c319 | 55 | * @return bullet_distance_counter |
| evanso | 20:febd920ec29e | 56 | */ |
| evanso | 20:febd920ec29e | 57 | int get_bullet_delete_counter(); |
| evanso | 20:febd920ec29e | 58 | |
| evanso | 20:febd920ec29e | 59 | /** Gets the bullet direction |
| evanso | 27:8bb2bd97c319 | 60 | * @return bullet_direction_ |
| evanso | 20:febd920ec29e | 61 | */ |
| evanso | 20:febd920ec29e | 62 | bool get_direction(); |
| evanso | 19:1bc0a2d22054 | 63 | |
| evanso | 19:1bc0a2d22054 | 64 | /** Sets the bullets movment direction when it is fired |
| evanso | 27:8bb2bd97c319 | 65 | * @param spaceship_sprite_direction_ @details sprite direction bool, |
| evanso | 27:8bb2bd97c319 | 66 | * true = E, false = W |
| evanso | 19:1bc0a2d22054 | 67 | */ |
| evanso | 28:a5958497d5ce | 68 | void set_direction(bool sprite_direction_); |
| evanso | 18:11068b98e261 | 69 | |
| evanso | 22:053c11a202e1 | 70 | private: |
| evanso | 22:053c11a202e1 | 71 | // Function prototypes ----------------------------------------------------- |
| evanso | 22:053c11a202e1 | 72 | |
| evanso | 19:1bc0a2d22054 | 73 | /** Calculates bullets start postion |
| evanso | 19:1bc0a2d22054 | 74 | * @param spaceship_pos @details x and y postion of spaceship |
| evanso | 27:8bb2bd97c319 | 75 | * @param spaceship_sprite_direction_ @details sprite direction bool, |
| evanso | 27:8bb2bd97c319 | 76 | * true = E, false = W |
| evanso | 19:1bc0a2d22054 | 77 | */ |
| evanso | 27:8bb2bd97c319 | 78 | void calc_bullets_start_pos(Vector2D spaceship_pos, |
| evanso | 27:8bb2bd97c319 | 79 | bool spaceship_sprite_direction_); |
| evanso | 28:a5958497d5ce | 80 | |
| evanso | 28:a5958497d5ce | 81 | /** Calculates allien bullets start postion |
| evanso | 28:a5958497d5ce | 82 | * @param alien_pos @details x and y postion of spaceship |
| evanso | 28:a5958497d5ce | 83 | * @param alien_sprite_direction_ @details sprite direction bool, |
| evanso | 28:a5958497d5ce | 84 | * true = E, false = W |
| evanso | 28:a5958497d5ce | 85 | */ |
| evanso | 28:a5958497d5ce | 86 | void calc_alien_bullets_start_pos(Vector2D alien_pos, |
| evanso | 28:a5958497d5ce | 87 | bool alien_sprite_direction_); |
| evanso | 20:febd920ec29e | 88 | |
| evanso | 16:1ee3d3804557 | 89 | // Variables --------------------------------------------------------------- |
| evanso | 16:1ee3d3804557 | 90 | |
| evanso | 27:8bb2bd97c319 | 91 | /** Counter to deleted bullet */ |
| evanso | 28:a5958497d5ce | 92 | int bullet_delete_counter_; |
| evanso | 16:1ee3d3804557 | 93 | }; |
| evanso | 16:1ee3d3804557 | 94 | |
| evanso | 16:1ee3d3804557 | 95 | #endif |