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.
MazeEngine/MazeEngine.cpp
- Committer:
- ahmedhedait
- Date:
- 2018-05-08
- Revision:
- 23:6733f8b9c321
- Parent:
- 22:745b4d352183
- Child:
- 25:28c57be06933
File content as of revision 23:6733f8b9c321:
#include "MazeEngine.h" // nothing doing in the constructor and destructor MazeEngine::MazeEngine() { } MazeEngine::~MazeEngine() { } void MazeEngine::init() { _ball.init(); } void MazeEngine::read_input(Gamepad &pad) { _dir = pad.get_direction(); // printf("direction %i\n", _dir); } void MazeEngine::update(Gamepad &pad) { _ball.check_wall_collision(pad); _ball.update(_dir); check_goal(pad); } void MazeEngine::draw(N5110 &lcd) { // draw the elements in the LCD buffer // maze _maze.draw(lcd); // ball _ball.draw(lcd); // HERE IS A SIMPLE CODE THAT WHEN THE BALL PASS THROUGH THE OPENING THEN THE SCREEN SHOULD BE CLEARED IN WHICH BRAVO IS PRINTED TO // TELL THE USER THE GAME IS FINISHED. if (ball_pos.x > 83 & ball_pos.y == 27) { print_win(lcd); } } void MazeEngine::check_goal(Gamepad &pad) { ball_pos = _ball.get_pos(); if(ball_pos.x > 83 & ball_pos.y == 27) { if(pad.check_event(Gamepad::START_PRESSED) == true) { init(); } } } void MazeEngine::print_win(N5110 &lcd) { lcd.clear(); lcd.printString(" Bravo! ",12,2); lcd.printString(" Press Start ",0,4); }