Character Animation and Movement controller

Committer:
rottenegg
Date:
Wed Apr 17 05:10:11 2019 +0000
Revision:
0:8fa72895d335
First Build with collision detection and controls animation modes when moving. It hold internal declaration for Analog Pins

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rottenegg 0:8fa72895d335 1 #include "CaMove.h"
rottenegg 0:8fa72895d335 2
rottenegg 0:8fa72895d335 3
rottenegg 0:8fa72895d335 4 AnalogIn ver(PTB10);
rottenegg 0:8fa72895d335 5 AnalogIn hoz(PTB11);
rottenegg 0:8fa72895d335 6
rottenegg 0:8fa72895d335 7 void CaMove::CMinit() {
rottenegg 0:8fa72895d335 8 _h = 40;
rottenegg 0:8fa72895d335 9 _v = 20;
rottenegg 0:8fa72895d335 10 _itr = 0;
rottenegg 0:8fa72895d335 11 mvp =0;
rottenegg 0:8fa72895d335 12 };
rottenegg 0:8fa72895d335 13
rottenegg 0:8fa72895d335 14 int CaMove::get_x() {
rottenegg 0:8fa72895d335 15 return _h;
rottenegg 0:8fa72895d335 16 };
rottenegg 0:8fa72895d335 17
rottenegg 0:8fa72895d335 18 int CaMove::get_y() {
rottenegg 0:8fa72895d335 19 return _v;
rottenegg 0:8fa72895d335 20 };
rottenegg 0:8fa72895d335 21
rottenegg 0:8fa72895d335 22 short int CaMove::get_itr() {
rottenegg 0:8fa72895d335 23 return _itr;
rottenegg 0:8fa72895d335 24 };
rottenegg 0:8fa72895d335 25
rottenegg 0:8fa72895d335 26 short int CaMove::get_mvp() {
rottenegg 0:8fa72895d335 27 return mvp;
rottenegg 0:8fa72895d335 28 };
rottenegg 0:8fa72895d335 29
rottenegg 0:8fa72895d335 30 void CaMove::CMmove(N5110 &lcd) {
rottenegg 0:8fa72895d335 31 if (hoz > 0.6f && lcd.getPixel((_h-1),(_v+7)) == 0) {
rottenegg 0:8fa72895d335 32 _h = _h - 2;
rottenegg 0:8fa72895d335 33 mvp = 0;//L
rottenegg 0:8fa72895d335 34 }
rottenegg 0:8fa72895d335 35 if (hoz < 0.4f && lcd.getPixel((_h+10),(_v+7)) == 0) {
rottenegg 0:8fa72895d335 36 _h = _h + 2;
rottenegg 0:8fa72895d335 37 mvp = 1;//R
rottenegg 0:8fa72895d335 38 }
rottenegg 0:8fa72895d335 39 if (ver > 0.6f && lcd.getPixel((_h+5),(_v-1)) == 0) {
rottenegg 0:8fa72895d335 40 _v = _v - 2;
rottenegg 0:8fa72895d335 41 mvp = 2;//F
rottenegg 0:8fa72895d335 42 }
rottenegg 0:8fa72895d335 43 if (ver < 0.4f && lcd.getPixel((_h+5),(_v+14)) == 0) {
rottenegg 0:8fa72895d335 44 _v = _v + 2;
rottenegg 0:8fa72895d335 45 mvp = 3;//B
rottenegg 0:8fa72895d335 46 }
rottenegg 0:8fa72895d335 47 if (_itr == 3) {
rottenegg 0:8fa72895d335 48 _itr = -1;
rottenegg 0:8fa72895d335 49 }
rottenegg 0:8fa72895d335 50 _itr++;
rottenegg 0:8fa72895d335 51 };
rottenegg 0:8fa72895d335 52
rottenegg 0:8fa72895d335 53
rottenegg 0:8fa72895d335 54
rottenegg 0:8fa72895d335 55