Yuheng Huo
/
hyh_copy_copy
test
chara/chara.cpp@3:31ff7b3e2005, 2020-05-15 (annotated)
- Committer:
- Neowless
- Date:
- Fri May 15 20:32:27 2020 +0000
- Revision:
- 3:31ff7b3e2005
test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Neowless | 3:31ff7b3e2005 | 1 | #include "chara.h" |
Neowless | 3:31ff7b3e2005 | 2 | |
Neowless | 3:31ff7b3e2005 | 3 | void chara::init(){ |
Neowless | 3:31ff7b3e2005 | 4 | int d[56] = { |
Neowless | 3:31ff7b3e2005 | 5 | 0,0,1,1,1,0,0, |
Neowless | 3:31ff7b3e2005 | 6 | 0,0,1,0,1,0,0, |
Neowless | 3:31ff7b3e2005 | 7 | 0,0,1,1,1,0,0, |
Neowless | 3:31ff7b3e2005 | 8 | 1,1,0,1,0,0,0, |
Neowless | 3:31ff7b3e2005 | 9 | 1,0,1,1,1,1,0, |
Neowless | 3:31ff7b3e2005 | 10 | 1,0,1,1,0,0,0, |
Neowless | 3:31ff7b3e2005 | 11 | 1,1,0,0,1,0,0, |
Neowless | 3:31ff7b3e2005 | 12 | 0,0,0,0,1,0,0 |
Neowless | 3:31ff7b3e2005 | 13 | }; |
Neowless | 3:31ff7b3e2005 | 14 | for(int i = 0; i<56;i++){ |
Neowless | 3:31ff7b3e2005 | 15 | data[i] = d[i]; |
Neowless | 3:31ff7b3e2005 | 16 | } |
Neowless | 3:31ff7b3e2005 | 17 | _xy.x = 0; |
Neowless | 3:31ff7b3e2005 | 18 | _xy.y = 25; |
Neowless | 3:31ff7b3e2005 | 19 | } |
Neowless | 3:31ff7b3e2005 | 20 | |
Neowless | 3:31ff7b3e2005 | 21 | void chara::update(Gamepad &pad, FXOS8700CQ &device){ |
Neowless | 3:31ff7b3e2005 | 22 | Data values = device.get_values(); |
Neowless | 3:31ff7b3e2005 | 23 | |
Neowless | 3:31ff7b3e2005 | 24 | if(pad.get_direction() == N){ |
Neowless | 3:31ff7b3e2005 | 25 | _xy.y = _xy.y -4; |
Neowless | 3:31ff7b3e2005 | 26 | }else{ |
Neowless | 3:31ff7b3e2005 | 27 | _xy.y = _xy.y + 2; |
Neowless | 3:31ff7b3e2005 | 28 | } |
Neowless | 3:31ff7b3e2005 | 29 | |
Neowless | 3:31ff7b3e2005 | 30 | if(values.ay>=0){ |
Neowless | 3:31ff7b3e2005 | 31 | _xy.x = _xy.x - int(values.ay*10); |
Neowless | 3:31ff7b3e2005 | 32 | }else if(values.ay<=0){ |
Neowless | 3:31ff7b3e2005 | 33 | _xy.x = _xy.x - int(values.ay*10); |
Neowless | 3:31ff7b3e2005 | 34 | } |
Neowless | 3:31ff7b3e2005 | 35 | |
Neowless | 3:31ff7b3e2005 | 36 | if(_xy.x>=77){ |
Neowless | 3:31ff7b3e2005 | 37 | _xy.x = 77; |
Neowless | 3:31ff7b3e2005 | 38 | }else if(_xy.x<=0){ |
Neowless | 3:31ff7b3e2005 | 39 | _xy.x=0; |
Neowless | 3:31ff7b3e2005 | 40 | } |
Neowless | 3:31ff7b3e2005 | 41 | if(_xy.y>=41){ |
Neowless | 3:31ff7b3e2005 | 42 | _xy.y = 41 ; |
Neowless | 3:31ff7b3e2005 | 43 | }else if(_xy.y<=7){ |
Neowless | 3:31ff7b3e2005 | 44 | _xy.y=7; |
Neowless | 3:31ff7b3e2005 | 45 | } |
Neowless | 3:31ff7b3e2005 | 46 | } |
Neowless | 3:31ff7b3e2005 | 47 | |
Neowless | 3:31ff7b3e2005 | 48 | void chara::display(N5110 &lcd){ |
Neowless | 3:31ff7b3e2005 | 49 | Bitmap c(data, 8, 7); |
Neowless | 3:31ff7b3e2005 | 50 | c.render(lcd, _xy.x, _xy.y); |
Neowless | 3:31ff7b3e2005 | 51 | } |
Neowless | 3:31ff7b3e2005 | 52 | |
Neowless | 3:31ff7b3e2005 | 53 | xy chara::getxy(){return _xy;} |
Neowless | 3:31ff7b3e2005 | 54 | |
Neowless | 3:31ff7b3e2005 | 55 |