![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
BlockheadEngine/BlockheadEngine.cpp
- Committer:
- adambakerwa
- Date:
- 2019-05-06
- Revision:
- 38:51ed5820ffe5
- Parent:
- 36:6f452777b9ce
- Child:
- 42:0dad7c359fa5
File content as of revision 38:51ed5820ffe5:
#include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "BlockheadEngine.h" //nothing needed doing in constructor or deconstructor BlockheadEngine::BlockheadEngine() { } BlockheadEngine::~BlockheadEngine() { } void BlockheadEngine::init() //intialise all variables for new game { _blockhead.init(); //intialise variables in blockhead class _pos = _lev.init(_pos); //intialise variables in level class and _pos struct } void BlockheadEngine::continueInit() //intialise all variables for continue game { _blockhead.continue_init(); //level not intialised and x/y cordinate of blockhead differs dpending on what level you are on _pos = _lev.init(_pos); //initialise variables in level class and _pos struct } int BlockheadEngine::playgame(N5110 &lcd, Gamepad &pad) //runs the game 'blockhead' { lcd.clear(); //clear lcd first _level = _blockhead.next_level(); //returns what level blockhead is on _pos = _lev.whatLevel(lcd, _level); //displays that level on lcd, as well as passes cordinates of moving platforms and spikes to _pos structs _blockhead.blockhead(_pos, lcd, pad); //controlls blcokhead depending on position in game, _gameover = _blockhead.gameover_flag(pad); //_gameover = 1 once blockhead dies lcd.refresh(); //updates screen return _gameover; //returns _gameover } int BlockheadEngine::highscore() { if (_level >= _highscore) { //if level reached is higher than current highscore _highscore = _level; //then _highscore = _level } return _highscore; //returns _highscore }