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: CrossyChicken/CrossyChicken.cpp
- Revision:
- 17:67dbdfcdcec2
- Parent:
- 16:8a65cccd9685
- Child:
- 18:6be4c3c94a3d
diff -r 8a65cccd9685 -r 67dbdfcdcec2 CrossyChicken/CrossyChicken.cpp
--- a/CrossyChicken/CrossyChicken.cpp Wed May 13 23:07:05 2020 +0000
+++ b/CrossyChicken/CrossyChicken.cpp Thu May 14 01:07:27 2020 +0000
@@ -241,10 +241,49 @@
}
}
-void CrossyChicken::drawWater()
+// the water sprites are going to 'move' to make it realistic
+void CrossyChicken::createWater(){
+ int state = 1;
+
+ for(it = 0; it != 21; it++)
+ {
+ // fsm for drawing safety lane background
+ switch(state)
+ {
+ case 1: // initial state
+ row_water_one[it].push_back('F'); // first type of water
+ state++; // transition to next state
+ break;
+ case 2:
+ row_water_one[it].push_back('S'); // second type of water
+ state++; // transition to state 3
+ break;
+
+ case 3:
+ row_water_one[it].push_back('T'); // third type of water
+ state = 1; // back to start state
+ break;
+ }
+ }
+}
+
+void CrossyChicken::moveWater()
{
+ for(it = 0; it != row_water_one.size(); it++){
+ graphics.moveWaterWithSpeed(&row_water_one[it]);
+ }
+}
-
+// if sprite goes out of bound then show again
+void CrossyChicken::loopWater(Water *sprite)
+{
+ // check if car goes out of bounds
+ if(sprite->x > 84+grid){
+ sprite->x = -4;
+
+ } else if(sprite->x < -4){
+ sprite->x = 84 + grid;
+ }
}
// make the frog move same speed as log