Yang Zhenye 201199680

Dependencies:   mbed

Committer:
yangzhenye
Date:
Thu May 14 14:13:03 2020 +0000
Revision:
5:fcad75e9b9e1
Parent:
4:eb8dca1dc341
Child:
6:4abef55fee88
first

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yangzhenye 5:fcad75e9b9e1 1 /*
yangzhenye 5:fcad75e9b9e1 2 ELEC2645 Embedded Systems Project
yangzhenye 5:fcad75e9b9e1 3 School of Electronic & Electrical Engineering
yangzhenye 5:fcad75e9b9e1 4 University of Leeds
yangzhenye 5:fcad75e9b9e1 5 2019/20
yangzhenye 5:fcad75e9b9e1 6
yangzhenye 5:fcad75e9b9e1 7 Name:Yang Zhenye
yangzhenye 5:fcad75e9b9e1 8 Username:el17zy
yangzhenye 5:fcad75e9b9e1 9 Student ID Number:201199680
yangzhenye 5:fcad75e9b9e1 10 Date:2020/5/12
yangzhenye 5:fcad75e9b9e1 11 */
yangzhenye 5:fcad75e9b9e1 12
yangzhenye 5:fcad75e9b9e1 13 #include "Rooney.h"
yangzhenye 5:fcad75e9b9e1 14
yangzhenye 5:fcad75e9b9e1 15 player::player(){}
yangzhenye 5:fcad75e9b9e1 16 player::~player(){}
yangzhenye 5:fcad75e9b9e1 17
yangzhenye 5:fcad75e9b9e1 18 int _stand[10][5] = {
yangzhenye 1:74f525027af6 19 {0,0,1,0,0},
yangzhenye 1:74f525027af6 20 {0,1,0,1,0},
yangzhenye 1:74f525027af6 21 {0,0,1,0,0},
yangzhenye 1:74f525027af6 22 {1,0,1,0,1},
yangzhenye 1:74f525027af6 23 {1,1,1,1,1},
yangzhenye 1:74f525027af6 24 {0,0,1,0,0},
yangzhenye 1:74f525027af6 25 {0,0,1,0,0},
yangzhenye 1:74f525027af6 26 {0,0,1,0,0},
yangzhenye 1:74f525027af6 27 {0,1,0,1,0},
yangzhenye 1:74f525027af6 28 {1,0,0,0,1},
yangzhenye 1:74f525027af6 29 };
yangzhenye 5:fcad75e9b9e1 30 int _left[5][10] = {
yangzhenye 1:74f525027af6 31 {0,0,0,1,1,0,0,0,0,1},
yangzhenye 1:74f525027af6 32 {0,1,0,0,1,0,0,0,1,0},
yangzhenye 1:74f525027af6 33 {1,0,1,1,1,1,1,1,0,0},
yangzhenye 1:74f525027af6 34 {0,1,0,0,1,0,0,0,1,0},
yangzhenye 1:74f525027af6 35 {0,0,0,1,1,0,0,0,0,1},
yangzhenye 1:74f525027af6 36 };
yangzhenye 5:fcad75e9b9e1 37 int _right[5][10] = {
yangzhenye 1:74f525027af6 38 {1,0,0,0,0,1,1,0,0,0},
yangzhenye 1:74f525027af6 39 {0,1,0,0,0,1,0,0,1,0},
yangzhenye 1:74f525027af6 40 {0,0,1,1,1,1,1,1,0,1},
yangzhenye 1:74f525027af6 41 {0,1,0,0,0,1,0,0,1,0},
yangzhenye 1:74f525027af6 42 {1,0,0,0,0,1,1,0,0,0},
yangzhenye 1:74f525027af6 43 };
yangzhenye 1:74f525027af6 44
yangzhenye 1:74f525027af6 45 void player::init(){
yangzhenye 3:30c81344beff 46 _player_x=38;
yangzhenye 3:30c81344beff 47 _player_y=5;
yangzhenye 1:74f525027af6 48 }
yangzhenye 5:fcad75e9b9e1 49 void player::set_palyer_x(float joy_x, int speed) {
yangzhenye 1:74f525027af6 50 _speed=speed;
yangzhenye 5:fcad75e9b9e1 51 if (joy_x < float(-0.5)){
yangzhenye 1:74f525027af6 52 _speed=-0.5;
yangzhenye 5:fcad75e9b9e1 53 _player_x=38+_speed;}
yangzhenye 5:fcad75e9b9e1 54 else if (_player_x<=0){
yangzhenye 5:fcad75e9b9e1 55 _speed = 0;
yangzhenye 1:74f525027af6 56 }
yangzhenye 5:fcad75e9b9e1 57 if (joy_x > float(0.5)){
yangzhenye 1:74f525027af6 58 _speed=0.5;
yangzhenye 5:fcad75e9b9e1 59 _player_x=38+_speed;}
yangzhenye 5:fcad75e9b9e1 60 else if (_player_x>=80){
yangzhenye 5:fcad75e9b9e1 61 _speed = 0;}
yangzhenye 1:74f525027af6 62 }
yangzhenye 5:fcad75e9b9e1 63
yangzhenye 2:baca89f466bc 64 void player::draw_gate(N5110 &lcd) {
yangzhenye 2:baca89f466bc 65 lcd.drawLine(unsigned int const x0,
yangzhenye 2:baca89f466bc 66 unsigned int const y0,
yangzhenye 2:baca89f466bc 67 unsigned int const x1,
yangzhenye 2:baca89f466bc 68 unsigned int const y1,
yangzhenye 2:baca89f466bc 69 FullBlack)
yangzhenye 5:fcad75e9b9e1 70 }
yangzhenye 5:fcad75e9b9e1 71
yangzhenye 3:30c81344beff 72 bool player::collisicon_flag() {
yangzhenye 3:30c81344beff 73 if ((_player_x == _x() - 2) && (_player_y == _y() - 5)) {
yangzhenye 3:30c81344beff 74 _collision_flag = true;
yangzhenye 3:30c81344beff 75 _player_score++;
yangzhenye 3:30c81344beff 76 }
yangzhenye 5:fcad75e9b9e1 77 int * player::get_form(rooneybody body){
yangzhenye 5:fcad75e9b9e1 78 if (body == left){
yangzhenye 1:74f525027af6 79 return *left}
yangzhenye 5:fcad75e9b9e1 80 else if (body == right){
yangzhenye 1:74f525027af6 81 return *right}
yangzhenye 5:fcad75e9b9e1 82 else if (body == stand){
yangzhenye 1:74f525027af6 83 return *stand}
yangzhenye 5:fcad75e9b9e1 84 lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(body));
yangzhenye 1:74f525027af6 85 int player::get_x(){
yangzhenye 3:30c81344beff 86 return _player_x;
yangzhenye 1:74f525027af6 87 }
yangzhenye 1:74f525027af6 88 int player::get_y(){
yangzhenye 3:30c81344beff 89 return _player_y;
yangzhenye 1:74f525027af6 90 }
yangzhenye 1:74f525027af6 91 int player::get_speed(){
yangzhenye 1:74f525027af6 92 return _speed;
yangzhenye 1:74f525027af6 93 }