Character Animation and Movement controller
Diff: CaMove.cpp
- Revision:
- 0:8fa72895d335
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CaMove.cpp Wed Apr 17 05:10:11 2019 +0000 @@ -0,0 +1,55 @@ +#include "CaMove.h" + + +AnalogIn ver(PTB10); +AnalogIn hoz(PTB11); + +void CaMove::CMinit() { + _h = 40; + _v = 20; + _itr = 0; + mvp =0; +}; + +int CaMove::get_x() { + return _h; +}; + +int CaMove::get_y() { + return _v; +}; + +short int CaMove::get_itr() { + return _itr; +}; + +short int CaMove::get_mvp() { + return mvp; +}; + +void CaMove::CMmove(N5110 &lcd) { + if (hoz > 0.6f && lcd.getPixel((_h-1),(_v+7)) == 0) { + _h = _h - 2; + mvp = 0;//L + } + if (hoz < 0.4f && lcd.getPixel((_h+10),(_v+7)) == 0) { + _h = _h + 2; + mvp = 1;//R + } + if (ver > 0.6f && lcd.getPixel((_h+5),(_v-1)) == 0) { + _v = _v - 2; + mvp = 2;//F + } + if (ver < 0.4f && lcd.getPixel((_h+5),(_v+14)) == 0) { + _v = _v + 2; + mvp = 3;//B + } + if (_itr == 3) { + _itr = -1; + } + _itr++; +}; + + + + \ No newline at end of file