Yang Zhenye 201199680
Dependencies: mbed
Roony/Roony.cpp@2:baca89f466bc, 2020-04-30 (annotated)
- Committer:
- yangzhenye
- Date:
- Thu Apr 30 07:08:09 2020 +0000
- Revision:
- 2:baca89f466bc
- Parent:
- 1:74f525027af6
- Child:
- 3:30c81344beff
complete menu and improve roony
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yangzhenye | 1:74f525027af6 | 1 | #include "Ronny.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 | 1:74f525027af6 | 30 | _x=38; |
yangzhenye | 1:74f525027af6 | 31 | _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 | 1:74f525027af6 | 37 | _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 | 1:74f525027af6 | 44 | _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 | 1:74f525027af6 | 56 | bool player::collisicon_flag() {} |
yangzhenye | 1:74f525027af6 | 57 | int * player::get_form(roonybody){ |
yangzhenye | 1:74f525027af6 | 58 | if (roonybody == left){ |
yangzhenye | 1:74f525027af6 | 59 | return *left} |
yangzhenye | 1:74f525027af6 | 60 | else if (ronnybody == right){ |
yangzhenye | 1:74f525027af6 | 61 | return *right} |
yangzhenye | 1:74f525027af6 | 62 | else if (ronnybody == stand){ |
yangzhenye | 1:74f525027af6 | 63 | return *stand} |
yangzhenye | 1:74f525027af6 | 64 | lcd.drawSprite(_x, _y, 5, 10, (int *)get_form(ronnybody)); |
yangzhenye | 1:74f525027af6 | 65 | int player::get_x(){ |
yangzhenye | 1:74f525027af6 | 66 | return _x; |
yangzhenye | 1:74f525027af6 | 67 | } |
yangzhenye | 1:74f525027af6 | 68 | int player::get_y(){ |
yangzhenye | 1:74f525027af6 | 69 | return _y; |
yangzhenye | 1:74f525027af6 | 70 | } |
yangzhenye | 1:74f525027af6 | 71 | int player::get_speed(){ |
yangzhenye | 1:74f525027af6 | 72 | return _speed; |
yangzhenye | 1:74f525027af6 | 73 | } |