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
Engine/Engine.cpp
- Committer:
- lewisgw
- Date:
- 2019-03-17
- Revision:
- 5:eda40cdde3e7
- Parent:
- 4:ce4eea1c2a28
- Child:
- 7:bbc2b75c1418
File content as of revision 5:eda40cdde3e7:
#include "Engine.h" Engine::Engine(){} Engine::~Engine(){} void Engine::init() { _moving_counter = 0; _jump_counter = 0; _direction = Left; _level = 0; _x = 40; _y = 40; } void Engine::read_input(Gamepad &gamepad) { _input.coord = gamepad.get_mapped_coord(); _input.A_flag = gamepad.check_event(Gamepad::A_PRESSED); } void Engine::process_y() { _skater.set_y_position( _input.A_flag, _jump_counter, _level ); _y = _skater.get_y_position(); _jump_counter = _skater.get_jump_counter(); } void Engine::process_x() { _skater.set_x_position( _input.coord.x, _moving_counter, _direction, _input.coord.y ); _x = _skater.get_x_position(); _moving_counter = _skater.get_moving_counter(); } void Engine::process_sprite() { _sprite = _skater.get_sprite_value(); _direction = _skater.get_direction(); } void Engine::find_level() { if((_x >= 1 && _x <= 30 && _y < 15) || (_x >= 45 && _x <= 80 && _y < 15)){ _level = 1; } else { _level = 0; } } void Engine::update_lcd(N5110 &lcd){ _skate_sprite = _skater.get_sprite(_sprite); lcd.drawSprite(_x,_y,17,10,(int *)_skate_sprite); lcd.drawLine(5,40,80,40,FILL_BLACK); lcd.drawLine(5,22,30,22,FILL_BLACK); lcd.drawLine(50,22,80,22,FILL_BLACK); }