![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
publish my project
Diff: Me/Me.cpp
- Revision:
- 0:9e95a5ef2659
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Me/Me.cpp Mon Apr 27 06:14:34 2020 +0000 @@ -0,0 +1,63 @@ +#include "Me.h" + +Me::Me() +{ + +} + +Me::~Me() +{ + +} + +void Me::init(int x,int y,int height,int width) +{ + _x = 41; //Initially set in the center of the screen + _y = 23; + _height = height; //3 The colltroller is 3 by 3 + _width = width; //3 + _speed = 2; + +} + +void Me::draw(N5110 &lcd) +{ + + lcd.drawRect(_x,_y,_width,_height,FILL_BLACK); +} + +void Me::update(Direction d) +{ + _speed =2; // scale is arbitrary, could be changed in future + + + if (d == N) { + _y-=_speed; //_y=_y-speed; + } if (d == S) { + _y+=_speed; + } if (d == E) { + _x+=_speed; //_x=_x+speed; + } if (d == W) { + _x-=_speed; + } + + if (_y < 11) { + _y = 11; //coboundary + } + if (_y > 34) { //lower boundary + _y = 34; + } + if (_x < 11) { //left border + _x = 11; + } + if (_x > 70) { //right border + _x = 70; + } + +} + + +Vector2D Me::get_pos() { + Vector2D p = {_x,_y}; + return p; +} \ No newline at end of file