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
EngineController/EngineController.cpp
- Committer:
- lewisgw
- Date:
- 2019-04-11
- Revision:
- 17:f377df4ea7b1
- Parent:
- 16:331be5c7ed80
- Child:
- 18:304700b5d8f8
File content as of revision 17:f377df4ea7b1:
#include "EngineController.h" int intro_text[12][42] = { { 1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, { 1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, { 1,1,0,0,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,1,1 }, { 1,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,1,1 }, { 1,1,0,0,0,0,0,1,1,0,1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1 }, { 1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, { 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0 }, { 0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,1,1,0,0,0 }, { 0,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0 }, { 0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0 }, { 1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,0 }, { 1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1 } }; // Constructor and destructor EngineController::EngineController() {} EngineController::~EngineController() {} void EngineController::init() { // Initialise the game engine, game counter and starting text flag. _game_engine.init(); _game_counter = 0; _speed_divider = 10; _start_platform = true; _change_speed_flag = false; } void EngineController::run_game_engine(N5110 &lcd, Gamepad &gamepad) { // The main game loop that first checks if the game has just started and runs // the game. check_for_start(lcd); if(_game_counter == 100) _game_counter = 0; update_game(lcd, gamepad); if (_game_counter % _speed_divider == 0) _game_engine.generate_level(_game_counter); _game_counter++; _player_score = _game_engine.get_player_score(); _speed_divider = int(-0.25*_player_score + 10); } void EngineController::check_for_start(N5110 &lcd) { // Print the intro text if the game has just started. if(_start_platform) print_intro_text(lcd); _game_engine.check_reset(lcd); _start_platform = _game_engine.get_start_platform(); } void EngineController::print_intro_text(N5110 &lcd) { lcd.drawLine(0,17,80,17,FILL_WHITE); lcd.drawSprite(40,4,12,42,(int *)intro_text); } void EngineController::update_game(N5110 &lcd, Gamepad &gamepad) { // Run the game engine. _game_engine.read_input(gamepad); _game_engine.set_level_condition(); _game_engine.process_y(); _game_engine.process_x(_game_counter); _game_engine.process_sprite(); _game_engine.check_coin_collision(); _game_engine.check_spikes_collision(); _game_engine.update_lcd(lcd); }