Character Animation and Movement controller
Revision 0:8fa72895d335, committed 2019-04-17
- Comitter:
- rottenegg
- Date:
- Wed Apr 17 05:10:11 2019 +0000
- Commit message:
- First Build with collision detection and controls animation modes when moving. It hold internal declaration for Analog Pins
Changed in this revision
CaMove.cpp | Show annotated file Show diff for this revision Revisions of this file |
CaMove.h | Show annotated file Show diff for this revision Revisions of this file |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CaMove.h Wed Apr 17 05:10:11 2019 +0000 @@ -0,0 +1,28 @@ +#ifndef CAMOVE_H +#define CAMOVE_H + +#include "mbed.h" +#include "N5110.h" + +class N5110; + +class CaMove { + + public: + void CMinit(); + void CMmove(N5110 &lcd); + int get_x(); + int get_y(); + short int get_itr(); + short int get_mvp(); + + + private: + short int mvp; + int _h; + int _v; + short int _itr; + +}; + +#endif