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
Enemy/Enemy.h@3:97cd7b3d89d0, 2019-04-28 (annotated)
- Committer:
- adat80
- Date:
- Sun Apr 28 16:55:24 2019 +0000
- Revision:
- 3:97cd7b3d89d0
- Parent:
- 2:88019d96e1da
- Child:
- 5:8bd09c675f28
Game menu and loop to re play game
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| adat80 | 1:3916f272663e | 1 | #ifndef ENEMY_H |
| adat80 | 1:3916f272663e | 2 | #define ENEMY_H |
| adat80 | 1:3916f272663e | 3 | |
| adat80 | 1:3916f272663e | 4 | #include "mbed.h" |
| adat80 | 1:3916f272663e | 5 | #include "N5110.h" |
| adat80 | 1:3916f272663e | 6 | #include "Gamepad.h" |
| adat80 | 1:3916f272663e | 7 | #include <time.h> |
| adat80 | 1:3916f272663e | 8 | |
| adat80 | 1:3916f272663e | 9 | |
| adat80 | 1:3916f272663e | 10 | /** CrossHairs Class |
| adat80 | 1:3916f272663e | 11 | @author Adam Jones, University of Leeds |
| adat80 | 1:3916f272663e | 12 | @brief Controls the Enemy Sprites in the Wall Defence game |
| adat80 | 1:3916f272663e | 13 | @date April 2017 |
| adat80 | 1:3916f272663e | 14 | */ |
| adat80 | 2:88019d96e1da | 15 | |
| adat80 | 2:88019d96e1da | 16 | |
| adat80 | 2:88019d96e1da | 17 | enum Action { waiting, moving, attacking, dying }; |
| adat80 | 2:88019d96e1da | 18 | |
| adat80 | 1:3916f272663e | 19 | class Enemy |
| adat80 | 1:3916f272663e | 20 | { |
| adat80 | 1:3916f272663e | 21 | |
| adat80 | 2:88019d96e1da | 22 | |
| adat80 | 2:88019d96e1da | 23 | |
| adat80 | 2:88019d96e1da | 24 | |
| adat80 | 1:3916f272663e | 25 | public: |
| adat80 | 1:3916f272663e | 26 | Enemy(); |
| adat80 | 1:3916f272663e | 27 | ~Enemy(); |
| adat80 | 2:88019d96e1da | 28 | |
| adat80 | 2:88019d96e1da | 29 | |
| adat80 | 2:88019d96e1da | 30 | |
| adat80 | 2:88019d96e1da | 31 | Action enemAction; |
| adat80 | 3:97cd7b3d89d0 | 32 | void init(float timeToAttack, float speed); |
| adat80 | 1:3916f272663e | 33 | void draw(N5110 &lcd); |
| adat80 | 2:88019d96e1da | 34 | void update(int fps); |
| adat80 | 1:3916f272663e | 35 | /// accessors and mutators |
| adat80 | 1:3916f272663e | 36 | Vector2D get_pos(); |
| adat80 | 1:3916f272663e | 37 | void set_pos(Vector2D p); |
| adat80 | 2:88019d96e1da | 38 | |
| adat80 | 2:88019d96e1da | 39 | |
| adat80 | 1:3916f272663e | 40 | void set_attack(bool attack); |
| adat80 | 1:3916f272663e | 41 | float get_timeToAttack(); |
| adat80 | 1:3916f272663e | 42 | |
| adat80 | 2:88019d96e1da | 43 | |
| adat80 | 2:88019d96e1da | 44 | void set_current_action(Action act); |
| adat80 | 3:97cd7b3d89d0 | 45 | Action get_current_action(); |
| adat80 | 2:88019d96e1da | 46 | |
| adat80 | 1:3916f272663e | 47 | void set_alive(bool alive); |
| adat80 | 1:3916f272663e | 48 | bool get_alive(); |
| adat80 | 2:88019d96e1da | 49 | |
| adat80 | 2:88019d96e1da | 50 | void set_value(float value); |
| adat80 | 2:88019d96e1da | 51 | float get_value(); |
| adat80 | 2:88019d96e1da | 52 | |
| adat80 | 1:3916f272663e | 53 | private: |
| adat80 | 1:3916f272663e | 54 | |
| adat80 | 3:97cd7b3d89d0 | 55 | float _x; |
| adat80 | 3:97cd7b3d89d0 | 56 | float _y; |
| adat80 | 2:88019d96e1da | 57 | |
| adat80 | 1:3916f272663e | 58 | bool _attack; |
| adat80 | 1:3916f272663e | 59 | bool _alive; |
| adat80 | 1:3916f272663e | 60 | float _timeToAttack; |
| adat80 | 3:97cd7b3d89d0 | 61 | float _speed; |
| adat80 | 2:88019d96e1da | 62 | |
| adat80 | 2:88019d96e1da | 63 | float _animationTick; |
| adat80 | 2:88019d96e1da | 64 | Action currentAction; |
| adat80 | 2:88019d96e1da | 65 | float _value; |
| adat80 | 2:88019d96e1da | 66 | |
| adat80 | 2:88019d96e1da | 67 | |
| adat80 | 2:88019d96e1da | 68 | |
| adat80 | 2:88019d96e1da | 69 | |
| adat80 | 1:3916f272663e | 70 | }; |
| adat80 | 1:3916f272663e | 71 | #endif |