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 Gamepad N5110
plane.cpp
00001 #include "plane.h" 00002 00003 void plane::init(){ 00004 _width = 7; 00005 _height = 8; 00006 int d[56] = { 00007 0,0,0,0,1,0,0, 00008 0,0,0,0,1,1,0, 00009 1,0,0,0,1,1,0, 00010 1,1,1,1,1,1,1, 00011 1,1,1,1,1,1,1, 00012 1,0,0,0,1,1,0, 00013 0,0,0,0,1,1,0, 00014 0,0,0,0,1,0,0 00015 }; 00016 for(int i = 0; i<56;i++){ 00017 data[i] = d[i]; 00018 } 00019 _xy.x = 0; 00020 _xy.y = 25; 00021 } 00022 00023 void plane::update(Gamepad &pad){ 00024 if(pad.get_direction() == N){ 00025 _xy.y = _xy.y - 1; 00026 }else if(pad.get_direction() == S){ 00027 _xy.y = _xy.y + 1; 00028 }else if(pad.get_direction() == W){ 00029 _xy.x = _xy.x - 1; 00030 }else if(pad.get_direction() == E){ 00031 _xy.x = _xy.x + 1; 00032 } 00033 } 00034 00035 void plane::display(N5110 &lcd){ 00036 unsigned int width = _width; 00037 unsigned int height = _height; 00038 Bitmap p(data, height, width); 00039 p.render(lcd, _xy.x, _xy.y); 00040 } 00041 00042 xy plane::getxy(){return _xy;} 00043 00044 int plane::getwidth(){return _width;} 00045 int plane::getheight(){return _height;}
Generated on Sun Aug 7 2022 13:50:18 by
1.7.2