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.
Dependencies: 4DGL-uLCD-SE PinDetect mbed-rtos mbed
Robot.h
00001 //robot 00002 class Robot 00003 { 00004 public: 00005 void drawFrog() { 00006 uLCD.filled_rectangle(XPosition-5,YPosition-5,XPosition+5,YPosition+5,RED); 00007 } 00008 00009 void drawOutline() { 00010 uLCD.line(0, 0 , 0, 127, BLACK); 00011 uLCD.line(0, 0 , 127, 0, BLACK); 00012 uLCD.line(127, 127 , 0, 127, BLACK); 00013 uLCD.line(127, 127 , 127, 0, BLACK); 00014 } 00015 00016 void drawGrass(int Xp,int Yp) { 00017 uLCD.filled_rectangle(Xp-10,Yp-10,Xp+10,Yp+10,GREEN); 00018 } 00019 00020 void drawBar(int Xp,int Yp) { 00021 uLCD.filled_rectangle(Xp-10,Yp-10,Xp+10,Yp+10,BLACK); 00022 } 00023 00024 void drawRoad(int Xp,int Yp) { 00025 uLCD.filled_rectangle(Xp-10,Yp-10,Xp+10,Yp+10,BLACK); 00026 uLCD.filled_rectangle(Xp-2,Yp-1,Xp+2,Yp+1,WHITE); 00027 } 00028 00029 void drawWater(int Xp,int Yp) { 00030 uLCD.filled_rectangle(Xp-10,Yp-10,Xp+10,Yp+10,BLUE); 00031 if(Xp == 11 || Xp == 53 || Xp == 95){ 00032 uLCD.filled_rectangle(Xp-6,Yp-6,Xp+6,Yp+6,GREEN); 00033 } 00034 } 00035 00036 void drawHelper(int Xp,int Yp) { 00037 if(Yp == 11) { 00038 drawBar(Xp,Yp); //Row 1 00039 } 00040 if(Yp == 32){ 00041 drawGrass(Xp,Yp); //Row 2 00042 } 00043 if(Yp == 53){ 00044 drawRoad(Xp,Yp); //Row 3 00045 } 00046 if(Yp == 74){ 00047 drawWater(Xp,Yp); //Row 4 00048 } 00049 if(Yp == 95){ 00050 drawRoad(Xp,Yp); //Row 5 00051 } 00052 if(Yp == 116){ 00053 drawGrass(Xp,Yp); //Row 6 00054 } 00055 } 00056 00057 void drawEraser() { 00058 drawHelper(XPosition,YPosition); 00059 } 00060 00061 void moveForward() { 00062 setYPosition(getYPosition() - 21); 00063 } 00064 void moveBackward() { 00065 setYPosition(getYPosition() + 21); 00066 } 00067 void moveLeft() { 00068 setXPosition(getXPosition() - 21); 00069 } 00070 void moveRight() { 00071 setXPosition(getXPosition() + 21); 00072 } 00073 00074 int getXPosition() { 00075 return XPosition; 00076 } 00077 int getYPosition() { 00078 return YPosition; 00079 } 00080 00081 void setXPosition(int x) { 00082 XPosition=x; 00083 } 00084 void setYPosition(int y) { 00085 YPosition=y; 00086 } 00087 00088 Robot() 00089 { 00090 XPosition = 95; 00091 YPosition = 116; 00092 } 00093 private: 00094 00095 int XPosition; 00096 int YPosition; 00097 };
Generated on Thu Jul 28 2022 21:21:25 by
1.7.2