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.
Rooney.cpp
00001 /* 00002 ELEC2645 Embedded Systems Project 00003 School of Electronic & Electrical Engineering 00004 University of Leeds 00005 2019/20 00006 00007 Name:Yang Zhenye 00008 Username:el17zy 00009 Student ID Number:201199680 00010 Date:2020/5/12 00011 */ 00012 00013 #include "Rooney.h" 00014 00015 player::player(){} 00016 player::~player(){} 00017 00018 int _stand[10][5] = { 00019 {0,0,1,0,0}, 00020 {0,1,0,1,0}, 00021 {0,0,1,0,0}, 00022 {1,0,1,0,1}, 00023 {1,1,1,1,1}, 00024 {0,0,1,0,0}, 00025 {0,0,1,0,0}, 00026 {0,0,1,0,0}, 00027 {0,1,0,1,0}, 00028 {1,0,0,0,1}, 00029 }; 00030 int _left[5][10] = { 00031 {0,0,0,1,1,0,0,0,0,1}, 00032 {0,1,0,0,1,0,0,0,1,0}, 00033 {1,0,1,1,1,1,1,1,0,0}, 00034 {0,1,0,0,1,0,0,0,1,0}, 00035 {0,0,0,1,1,0,0,0,0,1}, 00036 }; 00037 int _right[5][10] = { 00038 {1,0,0,0,0,1,1,0,0,0}, 00039 {0,1,0,0,0,1,0,0,1,0}, 00040 {0,0,1,1,1,1,1,1,0,1}, 00041 {0,1,0,0,0,1,0,0,1,0}, 00042 {1,0,0,0,0,1,1,0,0,0}, 00043 }; 00044 00045 void player::init(){ 00046 _player_x=38; 00047 _player_y=5; 00048 } 00049 void player::set_palyer_x(float joy_x, int speed) { 00050 _speed=speed; 00051 if (joy_x < float(-0.5)){ 00052 _speed=-0.5; 00053 _player_x=38+_speed;} 00054 else if (_player_x<=0){ 00055 _speed = 0; 00056 } 00057 if (joy_x > float(0.5)){ 00058 _speed=0.5; 00059 _player_x=38+_speed;} 00060 else if (_player_x>=80){ 00061 _speed = 0;} 00062 } 00063 00064 //void player::draw_gate(N5110 &lcd) { 00065 // lcd.drawLine(unsigned int const x0, 00066 // unsigned int const y0, 00067 // unsigned int const x1, 00068 // unsigned int const y1, 00069 // FullBlack) 00070 //} 00071 void player::add_score() 00072 { 00073 _score++; 00074 } 00075 int player::get_score() 00076 { 00077 return _score; 00078 } 00079 bool player::collision_flag() { 00080 if ((_player_x == _x - 2) && (_player_y == _y - 5)) { 00081 _collision_flag = true; 00082 _score++; 00083 } 00084 } 00085 int * player::get_form(rooneybody body){ 00086 if (body == left){ 00087 return *_left;} 00088 else if (body == right){ 00089 return *_right;} 00090 else if (body == stand){ 00091 return *_stand;}} 00092 int player::drawrooney(N5110 &lcd){ 00093 lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(body));} 00094 00095 int player::get_x(){ 00096 return _player_x; 00097 } 00098 int player::get_y(){ 00099 return _player_y; 00100 } 00101 int player::get_speed(){ 00102 return _speed; 00103 } 00104
Generated on Sat Jul 23 2022 06:49:37 by
 1.7.2
 1.7.2