Yang Zhenye 201199680
Dependencies: mbed
Diff: RooneyEngine/RooneyEngine.cpp
- Revision:
- 7:a69ae964412c
- Parent:
- 5:fcad75e9b9e1
- Child:
- 8:c02c278320c0
--- a/RooneyEngine/RooneyEngine.cpp Thu May 14 15:55:41 2020 +0000 +++ b/RooneyEngine/RooneyEngine.cpp Thu May 14 17:19:27 2020 +0000 @@ -10,9 +10,9 @@ Date:2020/5/12 */ -#include "RonneyEngine.h" +#include "RooneyEngine.h" - +char buffer[15]; RooneyEngine::RooneyEngine(){} RooneyEngine::~RooneyEngine(){} void RooneyEngine::init() { @@ -23,26 +23,26 @@ void RooneyEngine::reset() { _player_x=38; _player_y=5; - _collisicon_flag = false; + _collision_flag = false; _player_score = 0; - _x = WIDTH/2 - _size/2; - _y = HEIGHT/2 - _size/2; + _x = WIDTH/2 - 2/2; + _y = HEIGHT/2 - 2/2; } -void RonneyEngine::check_reset(N5110 &lcd, Gamepad &gamepad) { +void RooneyEngine::check_reset(N5110 &lcd, Gamepad &gamepad) { if(get_reset_flag()){ gamepad.leds_on(); lcd.clear(); for (int i = 0; i<60; i++) { lcd.printString("lose the game", 0, 2); lcd.printString("sccore:", 0, 4); - lcd,refresh(); wait(0.00001); sprintf(buffer,"%2d",_player_score); lcd.printString(buffer,16,4); reset(); } } + } void RooneyEngine::check_start(N5110 &lcd, Gamepad &gamepad) { if(_start_flag == true) { @@ -51,24 +51,25 @@ } void RooneyEngine::check_collision(Gamepad &gamepad) { - if ((_player_x == _x() - 2) && (_player_y == _y() - 5)) { + if ((_player_x == _x - 2) && (_player_y == _y - 5)) { _collision_flag = true; _player_score++; } + } -void RooneyEngine::get_score() { - return _player_score; - } +//int RooneyEngine::get_score() { + // return _player_score; + // } -void RooneyEngine::get_sprite() { - lcd.drawLine(unsigned int const x0, - unsigned int const y0, - unsigned int const x1, - unsigned int const y1, - FullBlack); - lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(ronnybody)); - lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); - } +//void RooneyEngine::get_sprite() { +// lcd.drawLine(unsigned int const x0, + // unsigned int const y0, + // unsigned int const x1, + // unsigned int const y1, + // FullBlack); + // lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(ronnybody)); + // lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); + // } void RooneyEngine::update_lcd(N5110 &lcd) { get_sprite(); @@ -77,8 +78,8 @@ lcd.printString(buffer,30,0); } -void RooneyEngine::get_ronney_x(Gamepad &gamepad) { - _speed=speed; +void RooneyEngine::get_rooney_x(Gamepad &gamepad) { + _speed=speed; if (joy_x < float(-0.5){ _speed=-0.5; _player_x=38+_speed;