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