Adam Baker 201166301
Dependencies: mbed Gamepad N5110
BlockheadEngine/BlockheadEngine.cpp@36:6f452777b9ce, 2019-05-05 (annotated)
- Committer:
- adambakerwa
- Date:
- Sun May 05 14:58:20 2019 +0000
- Revision:
- 36:6f452777b9ce
- Parent:
- 35:7d69c0822ea9
- Child:
- 38:51ed5820ffe5
more menu work
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adambakerwa | 25:230e4163cb6b | 1 | #include "mbed.h" |
adambakerwa | 25:230e4163cb6b | 2 | #include "Gamepad.h" |
adambakerwa | 25:230e4163cb6b | 3 | #include "N5110.h" |
adambakerwa | 25:230e4163cb6b | 4 | #include "BlockheadEngine.h" |
adambakerwa | 25:230e4163cb6b | 5 | |
adambakerwa | 25:230e4163cb6b | 6 | BlockheadEngine::BlockheadEngine() |
adambakerwa | 25:230e4163cb6b | 7 | { |
adambakerwa | 25:230e4163cb6b | 8 | |
adambakerwa | 25:230e4163cb6b | 9 | } |
adambakerwa | 25:230e4163cb6b | 10 | |
adambakerwa | 25:230e4163cb6b | 11 | BlockheadEngine::~BlockheadEngine() |
adambakerwa | 25:230e4163cb6b | 12 | { |
adambakerwa | 25:230e4163cb6b | 13 | |
adambakerwa | 25:230e4163cb6b | 14 | } |
adambakerwa | 25:230e4163cb6b | 15 | |
adambakerwa | 26:3319ddd5111d | 16 | void BlockheadEngine::init() |
adambakerwa | 26:3319ddd5111d | 17 | { |
adambakerwa | 35:7d69c0822ea9 | 18 | _runner.init(); |
adambakerwa | 26:3319ddd5111d | 19 | _pos = _lev.init(_pos); |
adambakerwa | 28:934bb0da48ab | 20 | |
adambakerwa | 27:c0fa8e41743b | 21 | |
adambakerwa | 26:3319ddd5111d | 22 | } |
adambakerwa | 26:3319ddd5111d | 23 | |
adambakerwa | 31:bf765e3961f1 | 24 | void BlockheadEngine::continueInit() |
adambakerwa | 31:bf765e3961f1 | 25 | { |
adambakerwa | 35:7d69c0822ea9 | 26 | _runner.continue_init(); |
adambakerwa | 31:bf765e3961f1 | 27 | _pos = _lev.init(_pos); |
adambakerwa | 31:bf765e3961f1 | 28 | |
adambakerwa | 31:bf765e3961f1 | 29 | |
adambakerwa | 31:bf765e3961f1 | 30 | } |
adambakerwa | 31:bf765e3961f1 | 31 | |
adambakerwa | 25:230e4163cb6b | 32 | int BlockheadEngine::playgame(N5110 &lcd, Gamepad &pad) |
adambakerwa | 25:230e4163cb6b | 33 | { |
adambakerwa | 36:6f452777b9ce | 34 | lcd.clear(); |
adambakerwa | 36:6f452777b9ce | 35 | |
adambakerwa | 34:911d7d05a8d2 | 36 | _level = _runner.next_level(); |
adambakerwa | 34:911d7d05a8d2 | 37 | _pos = _lev.whatLevel(lcd, _level); |
adambakerwa | 35:7d69c0822ea9 | 38 | _runner.blockhead(_pos, lcd, pad); |
adambakerwa | 35:7d69c0822ea9 | 39 | _gameover = _runner.gameover_flag(pad); |
adambakerwa | 36:6f452777b9ce | 40 | |
adambakerwa | 36:6f452777b9ce | 41 | lcd.refresh(); |
adambakerwa | 25:230e4163cb6b | 42 | |
adambakerwa | 25:230e4163cb6b | 43 | return _gameover; |
adambakerwa | 25:230e4163cb6b | 44 | } |
adambakerwa | 25:230e4163cb6b | 45 | |
adambakerwa | 36:6f452777b9ce | 46 | int BlockheadEngine::highscore() |
adambakerwa | 36:6f452777b9ce | 47 | { |
adambakerwa | 36:6f452777b9ce | 48 | if (_level >= _highscore) { |
adambakerwa | 36:6f452777b9ce | 49 | _highscore = _level; |
adambakerwa | 36:6f452777b9ce | 50 | } |
adambakerwa | 36:6f452777b9ce | 51 | |
adambakerwa | 36:6f452777b9ce | 52 | return _highscore; |
adambakerwa | 36:6f452777b9ce | 53 | } |
adambakerwa | 36:6f452777b9ce | 54 |