James Heavey
/
EL17JH
FINAL VERSION
BreakoutEngine/BreakoutEngine.h@119:473cac51ddf0, 2019-05-08 (annotated)
- Committer:
- jamesheavey
- Date:
- Wed May 08 14:49:01 2019 +0000
- Revision:
- 119:473cac51ddf0
- Parent:
- 118:a44365bf061a
- Child:
- 123:39740c246fc2
FINAL GAME, comment and add print f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jamesheavey | 27:1b5038b0a7a2 | 1 | #ifndef BREAKOUTENGINE_H |
jamesheavey | 27:1b5038b0a7a2 | 2 | #define BREAKOUTENGINE_H |
jamesheavey | 27:1b5038b0a7a2 | 3 | |
jamesheavey | 27:1b5038b0a7a2 | 4 | #include "mbed.h" |
jamesheavey | 27:1b5038b0a7a2 | 5 | #include "N5110.h" |
jamesheavey | 27:1b5038b0a7a2 | 6 | #include "Gamepad.h" |
jamesheavey | 27:1b5038b0a7a2 | 7 | #include "Ball.h" |
jamesheavey | 27:1b5038b0a7a2 | 8 | #include "Paddle.h" |
jamesheavey | 27:1b5038b0a7a2 | 9 | #include "Brick.h" |
jamesheavey | 29:5168318d3e88 | 10 | #include "Laser.h" |
jamesheavey | 114:280903dd7e06 | 11 | #include "Life_Powerup.h" |
jamesheavey | 27:1b5038b0a7a2 | 12 | |
jamesheavey | 27:1b5038b0a7a2 | 13 | #include <list> |
jamesheavey | 27:1b5038b0a7a2 | 14 | #include <iterator> |
jamesheavey | 114:280903dd7e06 | 15 | #include <ctime> // For time() |
jamesheavey | 114:280903dd7e06 | 16 | #include <cstdlib> // For srand() and rand() |
jamesheavey | 40:ac53905346fb | 17 | |
jamesheavey | 40:ac53905346fb | 18 | #define GAP_TOP 10 |
jamesheavey | 92:2e6d88e44f56 | 19 | #define GAP 2 |
jamesheavey | 86:01f33d94e496 | 20 | |
jamesheavey | 86:01f33d94e496 | 21 | /* BreajoutEngine Class |
jamesheavey | 86:01f33d94e496 | 22 | @author James Heavey, University of Leeds |
jamesheavey | 92:2e6d88e44f56 | 23 | @brief Controls the Breakout game |
jamesheavey | 86:01f33d94e496 | 24 | @date May 2019 |
jamesheavey | 92:2e6d88e44f56 | 25 | */ |
jamesheavey | 27:1b5038b0a7a2 | 26 | |
jamesheavey | 27:1b5038b0a7a2 | 27 | class BreakoutEngine |
jamesheavey | 27:1b5038b0a7a2 | 28 | { |
jamesheavey | 27:1b5038b0a7a2 | 29 | |
jamesheavey | 27:1b5038b0a7a2 | 30 | public: |
jamesheavey | 27:1b5038b0a7a2 | 31 | BreakoutEngine(); |
jamesheavey | 27:1b5038b0a7a2 | 32 | ~BreakoutEngine(); |
jamesheavey | 27:1b5038b0a7a2 | 33 | |
jamesheavey | 64:c3426b417ad9 | 34 | void init(int paddle_width,int paddle_height,int ball_size,int speed); |
jamesheavey | 105:4e7585d8e5e2 | 35 | void read_input(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 36 | void update(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 37 | void draw(N5110 &lcd); |
jamesheavey | 27:1b5038b0a7a2 | 38 | void lives_leds(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 39 | int get_lives(); |
jamesheavey | 27:1b5038b0a7a2 | 40 | int get_num_left(); |
jamesheavey | 47:1d1a827be81b | 41 | int get_prev_score(); |
jamesheavey | 64:c3426b417ad9 | 42 | void set_prev_score(int prev_score); |
jamesheavey | 81:735e5ee2c92a | 43 | bool check_loss(Gamepad &pad); |
jamesheavey | 30:e3d2f0ca416f | 44 | void inc_index(); |
jamesheavey | 30:e3d2f0ca416f | 45 | void reset_index(); |
jamesheavey | 81:735e5ee2c92a | 46 | void reset_game(); |
jamesheavey | 60:63d69184ec0a | 47 | void reset_num_left(); |
jamesheavey | 64:c3426b417ad9 | 48 | int get_score(); |
jamesheavey | 62:64559062e0ec | 49 | void inc_mult(); |
jamesheavey | 109:5ba766522df0 | 50 | void set_mult_zero(); |
jamesheavey | 99:d8f1570faa05 | 51 | int get_mult(); |
jamesheavey | 105:4e7585d8e5e2 | 52 | void set_paddle_motion(bool tilt, float sens); |
jamesheavey | 119:473cac51ddf0 | 53 | void check_life_powerup(); |
jamesheavey | 116:2793d31ca691 | 54 | void reset_paddle_lives(); |
jamesheavey | 92:2e6d88e44f56 | 55 | |
jamesheavey | 27:1b5038b0a7a2 | 56 | private: |
jamesheavey | 27:1b5038b0a7a2 | 57 | |
jamesheavey | 42:347c20a16ee6 | 58 | void check_wall_collisions(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 59 | void check_paddle_collisions(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 60 | void check_brick_collisions(Gamepad &pad); |
jamesheavey | 36:cb73014d3a99 | 61 | void check_laser_collisions(Gamepad &pad); |
jamesheavey | 114:280903dd7e06 | 62 | void check_powerup_collisions(Gamepad &pad); |
jamesheavey | 27:1b5038b0a7a2 | 63 | void print_scores(N5110 &lcd); |
jamesheavey | 92:2e6d88e44f56 | 64 | void dec_num_left(); |
jamesheavey | 92:2e6d88e44f56 | 65 | |
jamesheavey | 27:1b5038b0a7a2 | 66 | int _paddle_width; |
jamesheavey | 27:1b5038b0a7a2 | 67 | int _paddle_height; |
jamesheavey | 27:1b5038b0a7a2 | 68 | int _ball_size; |
jamesheavey | 27:1b5038b0a7a2 | 69 | int _speed; |
jamesheavey | 30:e3d2f0ca416f | 70 | int _index; |
jamesheavey | 62:64559062e0ec | 71 | int _multiplier; |
jamesheavey | 45:b1ac80481d4f | 72 | double _cool_time; |
jamesheavey | 92:2e6d88e44f56 | 73 | |
jamesheavey | 82:d1341d632890 | 74 | int _paddley; |
jamesheavey | 27:1b5038b0a7a2 | 75 | int _number_left; |
jamesheavey | 47:1d1a827be81b | 76 | int _prev_score; |
jamesheavey | 64:c3426b417ad9 | 77 | int _score; |
jamesheavey | 92:2e6d88e44f56 | 78 | |
jamesheavey | 27:1b5038b0a7a2 | 79 | Direction _d; |
jamesheavey | 27:1b5038b0a7a2 | 80 | float _mag; |
jamesheavey | 92:2e6d88e44f56 | 81 | |
jamesheavey | 86:01f33d94e496 | 82 | Paddle _paddle; |
jamesheavey | 92:2e6d88e44f56 | 83 | |
jamesheavey | 86:01f33d94e496 | 84 | Ball _ball; |
jamesheavey | 92:2e6d88e44f56 | 85 | |
jamesheavey | 35:3a614d539a54 | 86 | std::list<Laser> listofLasers; |
jamesheavey | 35:3a614d539a54 | 87 | std::list<Laser>::iterator it_L; |
jamesheavey | 92:2e6d88e44f56 | 88 | |
jamesheavey | 27:1b5038b0a7a2 | 89 | std::list<Brick> listofBricks; |
jamesheavey | 92:2e6d88e44f56 | 90 | std::list<Brick>::iterator it_R; |
jamesheavey | 92:2e6d88e44f56 | 91 | |
jamesheavey | 27:1b5038b0a7a2 | 92 | Brick _brick11; |
jamesheavey | 27:1b5038b0a7a2 | 93 | Brick _brick12; |
jamesheavey | 27:1b5038b0a7a2 | 94 | Brick _brick13; |
jamesheavey | 27:1b5038b0a7a2 | 95 | Brick _brick14; |
jamesheavey | 27:1b5038b0a7a2 | 96 | Brick _brick15; |
jamesheavey | 27:1b5038b0a7a2 | 97 | Brick _brick16; |
jamesheavey | 27:1b5038b0a7a2 | 98 | Brick _brick21; |
jamesheavey | 27:1b5038b0a7a2 | 99 | Brick _brick22; |
jamesheavey | 27:1b5038b0a7a2 | 100 | Brick _brick23; |
jamesheavey | 27:1b5038b0a7a2 | 101 | Brick _brick24; |
jamesheavey | 27:1b5038b0a7a2 | 102 | Brick _brick25; |
jamesheavey | 27:1b5038b0a7a2 | 103 | Brick _brick26; |
jamesheavey | 27:1b5038b0a7a2 | 104 | Brick _brick31; |
jamesheavey | 27:1b5038b0a7a2 | 105 | Brick _brick32; |
jamesheavey | 27:1b5038b0a7a2 | 106 | Brick _brick33; |
jamesheavey | 27:1b5038b0a7a2 | 107 | Brick _brick34; |
jamesheavey | 27:1b5038b0a7a2 | 108 | Brick _brick35; |
jamesheavey | 27:1b5038b0a7a2 | 109 | Brick _brick36; |
jamesheavey | 92:2e6d88e44f56 | 110 | |
jamesheavey | 30:e3d2f0ca416f | 111 | Laser _laser1; |
jamesheavey | 30:e3d2f0ca416f | 112 | Laser _laser2; |
jamesheavey | 30:e3d2f0ca416f | 113 | Laser _laser3; |
jamesheavey | 114:280903dd7e06 | 114 | |
jamesheavey | 114:280903dd7e06 | 115 | Life_Powerup _powerup; |
jamesheavey | 27:1b5038b0a7a2 | 116 | |
jamesheavey | 27:1b5038b0a7a2 | 117 | }; |
jamesheavey | 27:1b5038b0a7a2 | 118 | |
jamesheavey | 27:1b5038b0a7a2 | 119 | #endif |