FINAL VERSION

Dependencies:   mbed

Committer:
jamesheavey
Date:
Mon May 06 14:23:19 2019 +0000
Revision:
81:735e5ee2c92a
Parent:
80:f57acdb7121f
Child:
82:d1341d632890
cp;

Who changed what in which revision?

UserRevisionLine numberNew 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 27:1b5038b0a7a2 11
jamesheavey 27:1b5038b0a7a2 12 #include <list>
jamesheavey 27:1b5038b0a7a2 13 #include <iterator>
jamesheavey 40:ac53905346fb 14
jamesheavey 40:ac53905346fb 15 #define GAP_TOP 10
jamesheavey 80:f57acdb7121f 16 #define GAP 2
jamesheavey 27:1b5038b0a7a2 17 #define BRICK_WIDTH 12
jamesheavey 27:1b5038b0a7a2 18 #define BRICK_HEIGHT 4
jamesheavey 27:1b5038b0a7a2 19 #define PADDLE_WIDTH 15
jamesheavey 27:1b5038b0a7a2 20
jamesheavey 27:1b5038b0a7a2 21 class BreakoutEngine
jamesheavey 27:1b5038b0a7a2 22 {
jamesheavey 27:1b5038b0a7a2 23
jamesheavey 27:1b5038b0a7a2 24 public:
jamesheavey 27:1b5038b0a7a2 25 BreakoutEngine();
jamesheavey 27:1b5038b0a7a2 26 ~BreakoutEngine();
jamesheavey 27:1b5038b0a7a2 27
jamesheavey 64:c3426b417ad9 28 void init(int paddle_width,int paddle_height,int ball_size,int speed);
jamesheavey 72:7254d2a8a1cd 29 void read_input(Gamepad &pad, bool tilt, float sens);
jamesheavey 27:1b5038b0a7a2 30 void update(Gamepad &pad);
jamesheavey 27:1b5038b0a7a2 31 void draw(N5110 &lcd);
jamesheavey 27:1b5038b0a7a2 32 void lives_leds(Gamepad &pad);
jamesheavey 27:1b5038b0a7a2 33 int get_lives();
jamesheavey 27:1b5038b0a7a2 34 int get_num_left();
jamesheavey 47:1d1a827be81b 35 int get_prev_score();
jamesheavey 64:c3426b417ad9 36 void set_prev_score(int prev_score);
jamesheavey 81:735e5ee2c92a 37 bool check_loss(Gamepad &pad);
jamesheavey 30:e3d2f0ca416f 38 void inc_index();
jamesheavey 30:e3d2f0ca416f 39 void reset_index();
jamesheavey 81:735e5ee2c92a 40 void reset_game();
jamesheavey 60:63d69184ec0a 41 void reset_num_left();
jamesheavey 64:c3426b417ad9 42 int get_score();
jamesheavey 62:64559062e0ec 43 void inc_mult();
jamesheavey 62:64559062e0ec 44 void set_mult_zero();
jamesheavey 27:1b5038b0a7a2 45
jamesheavey 27:1b5038b0a7a2 46 private:
jamesheavey 27:1b5038b0a7a2 47
jamesheavey 42:347c20a16ee6 48 void check_wall_collisions(Gamepad &pad);
jamesheavey 27:1b5038b0a7a2 49 void check_paddle_collisions(Gamepad &pad);
jamesheavey 27:1b5038b0a7a2 50 void check_brick_collisions(Gamepad &pad);
jamesheavey 36:cb73014d3a99 51 void check_laser_collisions(Gamepad &pad);
jamesheavey 27:1b5038b0a7a2 52 void print_scores(N5110 &lcd);
jamesheavey 27:1b5038b0a7a2 53 void one_less();
jamesheavey 27:1b5038b0a7a2 54
jamesheavey 27:1b5038b0a7a2 55 Paddle _p1;
jamesheavey 27:1b5038b0a7a2 56
jamesheavey 27:1b5038b0a7a2 57 int _paddle_width;
jamesheavey 27:1b5038b0a7a2 58 int _paddle_height;
jamesheavey 27:1b5038b0a7a2 59 int _ball_size;
jamesheavey 27:1b5038b0a7a2 60 int _speed;
jamesheavey 30:e3d2f0ca416f 61 int _index;
jamesheavey 62:64559062e0ec 62 int _multiplier;
jamesheavey 45:b1ac80481d4f 63 double _cool_time;
jamesheavey 27:1b5038b0a7a2 64
jamesheavey 27:1b5038b0a7a2 65 // y positions of the paddle
jamesheavey 27:1b5038b0a7a2 66 int _p1y;
jamesheavey 27:1b5038b0a7a2 67 int _number_left;
jamesheavey 47:1d1a827be81b 68 int _prev_score;
jamesheavey 64:c3426b417ad9 69 int _score;
jamesheavey 27:1b5038b0a7a2 70
jamesheavey 27:1b5038b0a7a2 71 Ball _ball;
jamesheavey 27:1b5038b0a7a2 72
jamesheavey 27:1b5038b0a7a2 73 Direction _d;
jamesheavey 27:1b5038b0a7a2 74 float _mag;
jamesheavey 27:1b5038b0a7a2 75
jamesheavey 35:3a614d539a54 76 std::list<Laser> listofLasers;
jamesheavey 35:3a614d539a54 77 std::list<Laser>::iterator it_L;
jamesheavey 27:1b5038b0a7a2 78
jamesheavey 27:1b5038b0a7a2 79 std::list<Brick> listofBricks;
jamesheavey 58:a159cd976aca 80 std::list<Brick>::iterator it_R;
jamesheavey 27:1b5038b0a7a2 81
jamesheavey 27:1b5038b0a7a2 82 Brick _brick11;
jamesheavey 27:1b5038b0a7a2 83 Brick _brick12;
jamesheavey 27:1b5038b0a7a2 84 Brick _brick13;
jamesheavey 27:1b5038b0a7a2 85 Brick _brick14;
jamesheavey 27:1b5038b0a7a2 86 Brick _brick15;
jamesheavey 27:1b5038b0a7a2 87 Brick _brick16;
jamesheavey 27:1b5038b0a7a2 88
jamesheavey 27:1b5038b0a7a2 89 Brick _brick21;
jamesheavey 27:1b5038b0a7a2 90 Brick _brick22;
jamesheavey 27:1b5038b0a7a2 91 Brick _brick23;
jamesheavey 27:1b5038b0a7a2 92 Brick _brick24;
jamesheavey 27:1b5038b0a7a2 93 Brick _brick25;
jamesheavey 27:1b5038b0a7a2 94 Brick _brick26;
jamesheavey 27:1b5038b0a7a2 95
jamesheavey 27:1b5038b0a7a2 96 Brick _brick31;
jamesheavey 27:1b5038b0a7a2 97 Brick _brick32;
jamesheavey 27:1b5038b0a7a2 98 Brick _brick33;
jamesheavey 27:1b5038b0a7a2 99 Brick _brick34;
jamesheavey 27:1b5038b0a7a2 100 Brick _brick35;
jamesheavey 27:1b5038b0a7a2 101 Brick _brick36;
jamesheavey 27:1b5038b0a7a2 102
jamesheavey 30:e3d2f0ca416f 103 Laser _laser1;
jamesheavey 30:e3d2f0ca416f 104 Laser _laser2;
jamesheavey 30:e3d2f0ca416f 105 Laser _laser3;
jamesheavey 27:1b5038b0a7a2 106
jamesheavey 27:1b5038b0a7a2 107 };
jamesheavey 27:1b5038b0a7a2 108
jamesheavey 27:1b5038b0a7a2 109 #endif