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: mbed
Diff: GraphicEngine/GraphicEngine.cpp
- Revision:
- 52:1145e99264ea
- Parent:
- 51:4c1f49729d88
- Child:
- 53:b6bb4dab7823
--- a/GraphicEngine/GraphicEngine.cpp Mon May 25 16:58:50 2020 +0000
+++ b/GraphicEngine/GraphicEngine.cpp Mon May 25 17:53:05 2020 +0000
@@ -112,19 +112,43 @@
lcd.backLightOn();
}
-void GraphicEngine::showObj(Object *obj)
+void GraphicEngine::showObj(Object *obj, int turtles_state)
{
- if(obj->object.c == 'G' || obj->object.c == 'M' || obj->object.c == 'T') {
+ if(obj->object.c == 'G' || obj->object.c == 'M') {
displayLog(obj->object.x, obj->object.y, obj->object.c);
+ } else if(obj->object.c == 'T') {
+ displayTurtles(obj->object.x, obj->object.y, obj->object.c, turtles_state);
} else {
displayVehicle(obj->object.x, obj->object.y, obj->object.c);
- }
+ }
}
+
void GraphicEngine::drawDangerZone()
{
lcd.drawSprite(0, 48 - 4*11, 7, 83, (int *)danger_zone);
}
+void GraphicEngine::displayTurtles(int x, int y, char c, int turtle_sate){
+ switch(turtle_sate)
+ {
+ case 0 ... 1000:
+ lcd.drawSprite(x, y, 4, 20, (int *)turtles_state_one);
+ break;
+ case 1001 ... 2000:
+ lcd.drawSprite(x, y, 4, 20, (int *)turtles_state_one);
+ break;
+ case 2001 ... 3000:
+ lcd.drawSprite(x, y, 4, 20, (int *)turtles_state_two);
+ break;
+ case 3001 ... 4000:
+ lcd.drawSprite(x, y, 4, 20, (int *)turtles_state_two);
+ break;
+ case 4001 ... 5000:
+ lcd.drawSprite(x, y, 4, 20, (int *)turtles_state_three);
+ break;
+ }
+}
+
void GraphicEngine::displayVehicle(int x, int y, char c)
{
switch(c)
@@ -158,10 +182,6 @@
case 'M':
lcd.drawSprite(x, y, 4, 16, (int *)medium_log);
break;
-
- case 'T':
- lcd.drawSprite(x, y, 4, 12, (int *)turtles);
- break;
}
}
@@ -173,7 +193,7 @@
case 0:
lcd.drawSprite(x, y, 4, 6, (int *)frog_state_up);
break;
- case 1:
+ case 1:
lcd.drawSprite(x, y, 4, 6, (int *)frog_state_left);
break;
case 2:
@@ -215,5 +235,4 @@
void GraphicEngine::printCongrats()
{
lcd.printString("CONGTATS NEXT LEVEL!!!!",1,1);
-}
-
+}
\ No newline at end of file