Yang Zhenye 201199680
Dependencies: mbed
Rooney/Rooney.cpp@4:eb8dca1dc341, 2020-05-13 (annotated)
- Committer:
- yangzhenye
- Date:
- Wed May 13 14:55:07 2020 +0000
- Revision:
- 4:eb8dca1dc341
- Parent:
- Roony/Roony.cpp@3:30c81344beff
- Child:
- 5:fcad75e9b9e1
advance
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yangzhenye | 4:eb8dca1dc341 | 1 | #include "Ronney.h" |
yangzhenye | 1:74f525027af6 | 2 | int stand[5][10] = { |
yangzhenye | 1:74f525027af6 | 3 | {0,0,1,0,0}, |
yangzhenye | 1:74f525027af6 | 4 | {0,1,0,1,0}, |
yangzhenye | 1:74f525027af6 | 5 | {0,0,1,0,0}, |
yangzhenye | 1:74f525027af6 | 6 | {1,0,1,0,1}, |
yangzhenye | 1:74f525027af6 | 7 | {1,1,1,1,1}, |
yangzhenye | 1:74f525027af6 | 8 | {0,0,1,0,0}, |
yangzhenye | 1:74f525027af6 | 9 | {0,0,1,0,0}, |
yangzhenye | 1:74f525027af6 | 10 | {0,0,1,0,0}, |
yangzhenye | 1:74f525027af6 | 11 | {0,1,0,1,0}, |
yangzhenye | 1:74f525027af6 | 12 | {1,0,0,0,1}, |
yangzhenye | 1:74f525027af6 | 13 | }; |
yangzhenye | 1:74f525027af6 | 14 | int left[10][5] = { |
yangzhenye | 1:74f525027af6 | 15 | {0,0,0,1,1,0,0,0,0,1}, |
yangzhenye | 1:74f525027af6 | 16 | {0,1,0,0,1,0,0,0,1,0}, |
yangzhenye | 1:74f525027af6 | 17 | {1,0,1,1,1,1,1,1,0,0}, |
yangzhenye | 1:74f525027af6 | 18 | {0,1,0,0,1,0,0,0,1,0}, |
yangzhenye | 1:74f525027af6 | 19 | {0,0,0,1,1,0,0,0,0,1}, |
yangzhenye | 1:74f525027af6 | 20 | }; |
yangzhenye | 1:74f525027af6 | 21 | int right[10][5] = { |
yangzhenye | 1:74f525027af6 | 22 | {1,0,0,0,0,1,1,0,0,0}, |
yangzhenye | 1:74f525027af6 | 23 | {0,1,0,0,0,1,0,0,1,0}, |
yangzhenye | 1:74f525027af6 | 24 | {0,0,1,1,1,1,1,1,0,1}, |
yangzhenye | 1:74f525027af6 | 25 | {0,1,0,0,0,1,0,0,1,0}, |
yangzhenye | 1:74f525027af6 | 26 | {1,0,0,0,0,1,1,0,0,0}, |
yangzhenye | 1:74f525027af6 | 27 | }; |
yangzhenye | 1:74f525027af6 | 28 | |
yangzhenye | 1:74f525027af6 | 29 | void player::init(){ |
yangzhenye | 3:30c81344beff | 30 | _player_x=38; |
yangzhenye | 3:30c81344beff | 31 | _player_y=5; |
yangzhenye | 1:74f525027af6 | 32 | } |
yangzhenye | 1:74f525027af6 | 33 | void player::set_palyer_x(float joy_x int speed) { |
yangzhenye | 1:74f525027af6 | 34 | _speed=speed; |
yangzhenye | 1:74f525027af6 | 35 | if (joy_x < float(-0.5){ |
yangzhenye | 1:74f525027af6 | 36 | _speed=-0.5; |
yangzhenye | 3:30c81344beff | 37 | _player_x=38+_speed; |
yangzhenye | 1:74f525027af6 | 38 | else if (x<=0){ |
yangzhenye | 1:74f525027af6 | 39 | _speed = 0 |
yangzhenye | 1:74f525027af6 | 40 | } |
yangzhenye | 1:74f525027af6 | 41 | } |
yangzhenye | 1:74f525027af6 | 42 | if (joy_x > float(0.5){ |
yangzhenye | 1:74f525027af6 | 43 | _speed=0.5; |
yangzhenye | 3:30c81344beff | 44 | _player_x=38+_speed; |
yangzhenye | 1:74f525027af6 | 45 | else if (x>=80){ |
yangzhenye | 1:74f525027af6 | 46 | _speed = 0 |
yangzhenye | 1:74f525027af6 | 47 | } |
yangzhenye | 1:74f525027af6 | 48 | } |
yangzhenye | 2:baca89f466bc | 49 | void player::draw_gate(N5110 &lcd) { |
yangzhenye | 2:baca89f466bc | 50 | lcd.drawLine(unsigned int const x0, |
yangzhenye | 2:baca89f466bc | 51 | unsigned int const y0, |
yangzhenye | 2:baca89f466bc | 52 | unsigned int const x1, |
yangzhenye | 2:baca89f466bc | 53 | unsigned int const y1, |
yangzhenye | 2:baca89f466bc | 54 | FullBlack) |
yangzhenye | 2:baca89f466bc | 55 | { |
yangzhenye | 3:30c81344beff | 56 | bool player::collisicon_flag() { |
yangzhenye | 3:30c81344beff | 57 | if ((_player_x == _x() - 2) && (_player_y == _y() - 5)) { |
yangzhenye | 3:30c81344beff | 58 | _collision_flag = true; |
yangzhenye | 3:30c81344beff | 59 | _player_score++; |
yangzhenye | 3:30c81344beff | 60 | } |
yangzhenye | 4:eb8dca1dc341 | 61 | int * player::get_form(rooneybody){ |
yangzhenye | 4:eb8dca1dc341 | 62 | if (rooneybody == left){ |
yangzhenye | 1:74f525027af6 | 63 | return *left} |
yangzhenye | 4:eb8dca1dc341 | 64 | else if (ronneybody == right){ |
yangzhenye | 1:74f525027af6 | 65 | return *right} |
yangzhenye | 4:eb8dca1dc341 | 66 | else if (ronneybody == stand){ |
yangzhenye | 1:74f525027af6 | 67 | return *stand} |
yangzhenye | 4:eb8dca1dc341 | 68 | lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(ronneybody)); |
yangzhenye | 1:74f525027af6 | 69 | int player::get_x(){ |
yangzhenye | 3:30c81344beff | 70 | return _player_x; |
yangzhenye | 1:74f525027af6 | 71 | } |
yangzhenye | 1:74f525027af6 | 72 | int player::get_y(){ |
yangzhenye | 3:30c81344beff | 73 | return _player_y; |
yangzhenye | 1:74f525027af6 | 74 | } |
yangzhenye | 1:74f525027af6 | 75 | int player::get_speed(){ |
yangzhenye | 1:74f525027af6 | 76 | return _speed; |
yangzhenye | 1:74f525027af6 | 77 | } |