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 FATFileSystem
Diff: CaMove/CaMove.cpp
- Revision:
- 10:4fda7b01484a
- Parent:
- 9:ac396c818874
- Child:
- 13:95323e0f2fcb
--- a/CaMove/CaMove.cpp Thu Apr 25 01:31:32 2019 +0000 +++ b/CaMove/CaMove.cpp Fri Apr 26 02:31:11 2019 +0000 @@ -163,6 +163,8 @@ //AI Components void CaMove::AIinit() { enabled = false; + _ch = 0; + _cv = 0; }; void CaMove::spawn(int x, int y) { @@ -171,23 +173,33 @@ _cv = y; } -void CaMove::chase(N5110 &lcd) { +void CaMove::chase(N5110 &lcd, int girl) { + int increment; + if (girl == 2) { + increment = 1; + } else { + increment = 3; + } if (enabled) { if (_cv < _v) { - _cv = _cv + 2; + _cv = _cv + increment; } else if (_cv > _v) { - _cv = _cv - 2; + _cv = _cv - increment; } else if (_ch < _h) { - _ch = _ch + 2; + _ch = _ch + 3; } else if (_ch > _v) { - _ch = _ch - 2; + _ch = _ch - 3; } - Bitmap::renderBMP(AIC[_itr],lcd,_ch,_cv); + if (girl == 2) { + Bitmap::renderBMP(AIC[_itr],lcd,_ch,_cv); + } else { + Bitmap::renderBMP(AIM[_itr],lcd,_ch,_cv); + } } } bool CaMove::is_caught() { - if ((abs(_ch - _h) < 10) && (abs(_cv - _v) < 14)) { + if (abs(_ch - _h) < 10 && abs(_cv - _v) < 14 && enabled) { return true; } else { return false;