Class used to run the maze game loop.
MazeEngine.cpp@0:afee1085c5ef, 2017-04-07 (annotated)
- Committer:
- el15mh
- Date:
- Fri Apr 07 10:29:16 2017 +0000
- Revision:
- 0:afee1085c5ef
- Child:
- 1:5a44ce88c5e2
whole program basic with menu interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15mh | 0:afee1085c5ef | 1 | /* |
el15mh | 0:afee1085c5ef | 2 | |
el15mh | 0:afee1085c5ef | 3 | @file mazeEngine.cpp |
el15mh | 0:afee1085c5ef | 4 | |
el15mh | 0:afee1085c5ef | 5 | (c) Max Houghton 19.03.2017 |
el15mh | 0:afee1085c5ef | 6 | Roller Maze Project, ELEC2645, Univeristy of Leeds |
el15mh | 0:afee1085c5ef | 7 | |
el15mh | 0:afee1085c5ef | 8 | */ |
el15mh | 0:afee1085c5ef | 9 | |
el15mh | 0:afee1085c5ef | 10 | #include "MazeEngine.h" |
el15mh | 0:afee1085c5ef | 11 | |
el15mh | 0:afee1085c5ef | 12 | MazeEngine::MazeEngine() |
el15mh | 0:afee1085c5ef | 13 | { |
el15mh | 0:afee1085c5ef | 14 | |
el15mh | 0:afee1085c5ef | 15 | } |
el15mh | 0:afee1085c5ef | 16 | |
el15mh | 0:afee1085c5ef | 17 | MazeEngine::~MazeEngine() |
el15mh | 0:afee1085c5ef | 18 | { |
el15mh | 0:afee1085c5ef | 19 | |
el15mh | 0:afee1085c5ef | 20 | } |
el15mh | 0:afee1085c5ef | 21 | |
el15mh | 0:afee1085c5ef | 22 | void MazeEngine::init(int mazeIndex, int x, int y, int radius) |
el15mh | 0:afee1085c5ef | 23 | { |
el15mh | 0:afee1085c5ef | 24 | // maze parameters |
el15mh | 0:afee1085c5ef | 25 | _mazeIndex = mazeIndex; |
el15mh | 0:afee1085c5ef | 26 | |
el15mh | 0:afee1085c5ef | 27 | // ball parameters |
el15mh | 0:afee1085c5ef | 28 | _radius = radius; |
el15mh | 0:afee1085c5ef | 29 | _x = x; |
el15mh | 0:afee1085c5ef | 30 | _y = y; |
el15mh | 0:afee1085c5ef | 31 | |
el15mh | 0:afee1085c5ef | 32 | // initialise ball & maze with parameters |
el15mh | 0:afee1085c5ef | 33 | _ball.init(_x, _y, _radius); |
el15mh | 0:afee1085c5ef | 34 | _maze.init(_mazeIndex); |
el15mh | 0:afee1085c5ef | 35 | } |
el15mh | 0:afee1085c5ef | 36 | |
el15mh | 0:afee1085c5ef | 37 | void MazeEngine::readInput(Gamepad &pad, FXOS8700CQ &device) |
el15mh | 0:afee1085c5ef | 38 | { |
el15mh | 0:afee1085c5ef | 39 | // acquire input from devices |
el15mh | 0:afee1085c5ef | 40 | _direction = pad.get_direction(); // direction is a 2D struct |
el15mh | 0:afee1085c5ef | 41 | _magnitude = pad.get_mag(); |
el15mh | 0:afee1085c5ef | 42 | /* |
el15mh | 0:afee1085c5ef | 43 | else { |
el15mh | 0:afee1085c5ef | 44 | |
el15mh | 0:afee1085c5ef | 45 | _direction = devie. |
el15mh | 0:afee1085c5ef | 46 | } |
el15mh | 0:afee1085c5ef | 47 | */ |
el15mh | 0:afee1085c5ef | 48 | } |
el15mh | 0:afee1085c5ef | 49 | |
el15mh | 0:afee1085c5ef | 50 | void MazeEngine::update(Gamepad &pad, N5110 &lcd) |
el15mh | 0:afee1085c5ef | 51 | { |
el15mh | 0:afee1085c5ef | 52 | _ball.update(); |
el15mh | 0:afee1085c5ef | 53 | |
el15mh | 0:afee1085c5ef | 54 | } |
el15mh | 0:afee1085c5ef | 55 | |
el15mh | 0:afee1085c5ef | 56 | void MazeEngine::draw(N5110 &lcd) |
el15mh | 0:afee1085c5ef | 57 | { |
el15mh | 0:afee1085c5ef | 58 | _ball.draw(lcd); |
el15mh | 0:afee1085c5ef | 59 | _maze.draw(lcd); |
el15mh | 0:afee1085c5ef | 60 | } |
el15mh | 0:afee1085c5ef | 61 | |
el15mh | 0:afee1085c5ef | 62 |