Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Gamepad N5110
BlockheadEngine.cpp
00001 #include "mbed.h" 00002 #include "Gamepad.h" 00003 #include "N5110.h" 00004 #include "BlockheadEngine.h" 00005 00006 //nothing needed doing in constructor or deconstructor 00007 BlockheadEngine::BlockheadEngine() 00008 { 00009 00010 } 00011 00012 BlockheadEngine::~BlockheadEngine() 00013 { 00014 00015 } 00016 00017 00018 //intialise all variables for new game 00019 void BlockheadEngine::init() 00020 { 00021 _blockhead.init(); //intialise variables in blockhead class 00022 _pos = _lev.init(_pos); //intialise variables in level class and _pos struct 00023 00024 00025 } 00026 00027 00028 //intialise all variables for continue game 00029 void BlockheadEngine::continue_init() 00030 { 00031 _blockhead.continue_init(); //level not intialised and x/y cordinate of blockhead differs dpending on what level you are on 00032 _pos = _lev.init(_pos); //initialise variables in level class and _pos struct 00033 00034 00035 } 00036 00037 00038 //runs the game 'blockhead' 00039 int BlockheadEngine::playgame(N5110 &lcd, Gamepad &pad) 00040 { 00041 lcd.clear(); //clear lcd first 00042 00043 _level = _blockhead.next_level(); //returns what level blockhead is on 00044 _pos = _lev.what_level(lcd, _level); //displays that level on lcd, as well as passes cordinates of moving platforms and spikes to _pos structs 00045 _blockhead.blockhead(_pos, lcd, pad); //controlls blcokhead depending on position in game, 00046 _gameover = _blockhead.gameover_flag(pad); //_gameover = 1 once blockhead dies 00047 00048 lcd.refresh(); //updates screen 00049 00050 return _gameover; //returns _gameover 00051 } 00052 00053 00054 //returns highscore (the highest level reached by user) 00055 int BlockheadEngine::highscore() 00056 { 00057 if (_level >= _highscore) { //if level reached is higher than current highscore 00058 _highscore = _level; //then _highscore = _level 00059 } 00060 00061 return _highscore; //returns _highscore 00062 } 00063
Generated on Fri Jul 15 2022 00:42:15 by
