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
RosenEngine/RosenEngine.cpp
- Committer:
- ikenna1
- Date:
- 2019-04-10
- Revision:
- 14:88ca5b1a111a
- Parent:
- 13:e114d362186d
- Child:
- 15:009ccc07bb57
File content as of revision 14:88ca5b1a111a:
#include "RosenEngine.h" DigitalIn A_button(PTB9); // Constructor RosenEngine::RosenEngine() { } // Destructor RosenEngine::~RosenEngine() { } void RosenEngine::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos) { // initialise the game parameters _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos); _menu.init(16); } void RosenEngine::read_input(Gamepad &pad) { Vector2D mapped_coord = pad.get_coord(); _xjoystick = mapped_coord.x; _yjoystick = mapped_coord.y; _d = pad.get_direction(); // printf("_xjoystick ,_yjoystick = %f , %f\n",_xjoystick, _yjoystick); } void RosenEngine::draw(N5110 &lcd, Gamepad &pad) { if(_xcursor == 0) { _ship.set_dimensions(9,6); _ship.draw_ship(lcd); _weapons.draw(lcd); } if(_xcursor == 1) { _ship.set_dimensions(7,10); _ship.draw_imperion(lcd); if((A_button) == true) { pad.tone(500,0.5); wait(0.5); pad.tone(1000,0.3); wait(0.3); pad.tone(1500,0.2); wait(0.2); pad.tone(1700,0.15); wait(0.15); while((A_button) == true) { _weapons.draw_i(lcd); pad.tone(2000,0.1); wait(0.1); } } } } void RosenEngine::update(Gamepad &pad) { if(_xcursor == 0) { _ship.update_ship(_xjoystick,_yjoystick); _weapons.update(); } if(_xcursor == 1 && A_button == false) { _ship.update_ship(_xjoystick,_yjoystick); _weapons.update(); } // _menu.update(_d); } void RosenEngine::get_pos() { Vector2D ship_pos = _ship.get_pos(); ship_xpos = ship_pos.x; ship_ypos = ship_pos.y; ship_width = 9; _weapons.init(ship_xpos, ship_ypos, ship_width); _ycursor = _menu.get_ycursor(); } void RosenEngine::title(N5110 &lcd) { _menu.title(lcd); _menu.update(_d); } int RosenEngine::get_ycursor() { _ycursor = _menu.get_ycursor(); return _ycursor; } int RosenEngine::get_xcursor() { _xcursor = _menu.get_xcursor(); return _xcursor; } void RosenEngine::ship_select(N5110 &lcd) { _menu.update(_d); _menu.disp_ships(lcd); }