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.
Diff: LevelDefinitions/LevelDefinitions.h
- Revision:
- 10:58cf89dd878c
- Parent:
- 9:96969b1c6bde
- Child:
- 11:db27d3838514
--- a/LevelDefinitions/LevelDefinitions.h Wed Apr 24 10:18:45 2019 +0000
+++ b/LevelDefinitions/LevelDefinitions.h Mon May 06 10:11:42 2019 +0000
@@ -1,10 +1,11 @@
-
+// Struct for defining moving blocks
struct MovingBlockDefinition {
int index;
bool extending;
int distance;
};
+// Struct for defining levels.
struct LevelDefinition {
Block blocks [20];
int number_of_blocks;
@@ -13,28 +14,32 @@
Vector2D initial_pos;
Vector2D goal;
};
+///////////////// EXAMPLE DEFINITION /////////////////////////
// const LevelDefinition level_1 = {
-// // Define Blocks
-// {
-// { {5,30},{80,40} },
-// { {5,5}, {80,10} },
+// // Define Blocks // Array of blocks
+// { // Blocks are defined by their top left followed
+// { {5,30},{80,40} }, // by there bottom right coord. MUST be in that
+// { {5,5}, {80,10} }, // order.
// { {10,24},{20,34} },
// { {40,24},{44,26} }
// },
// // Number Of Blocks
// 4,
-// // Moving Blocks
-// {
-// {3,'x',25},
-// },
-// // Number Of Moving blocks
-// 1,
-// // Initial Position
-// {32,10},
+// // Moving Blocks // Movingblocks are defined as:
+// { // {index,extending,distance}
+// {3,true,25}, // index is the index in the block array
+// }, // of the block which you want to move
+// // Number Of Moving blocks extending is a bool if the block starts in
+// 1, // its extending/retracting phase
+// // Initial Position // distance is the horizontal distance the block
+// {32,10}, // moves.
// // Goal
// {70,19}
//};
-
+//
+// NOTE: MAX no. of blocks is 20 MAX no. of moving blocks is 10
+//
+//////////////////////////////////////////////////////////////
const LevelDefinition level_1 = {
// Define Blocks
{
@@ -101,11 +106,11 @@
const LevelDefinition level_4 = {
// Define Blocks
{
- { {5,8}, {60,10} },
+ { {4,8}, {60,10} },
{ {50,10},{60,30} },
{ {20,22},{50,30} },
- { {1,1}, {5,10} },
- { {5,40}, {57,50} }
+ { {0,0}, {5,10} },
+ { {5,40}, {58,50} }
},
// Number Of Blocks
@@ -194,3 +199,60 @@
{77,13}
};
+ const LevelDefinition level_8 = {
+ // Define Blocks
+ {
+ {{10,10},{64,14}},
+ {{20,0},{22,14}},
+
+ {{0,40},{10,44}},
+
+
+ {{20,20},{24,48}},
+ {{36,14},{40,32}},
+ {{50,20},{54,48}},
+ {{60,14},{64,32}},
+
+ {{66,0},{84,2}},
+
+ },
+ // Number Of Blocks
+ 8,
+ // Moving Blocks
+ {
+ {2,false,70},
+ },
+ // Number Of Moving blocks
+ 1,
+ // Initial Position
+ {10,0},
+ // Goal
+ {24,-1}
+};
+
+ const LevelDefinition level_9 = {
+ // Define Blocks
+ {
+ {{0,30},{10,48}},
+ {{10,44},{18,48}},
+ {{24,44},{84,48}},
+ {{12,10},{20,14}},
+ {{2,0},{18,4}}
+
+
+
+ },
+ // Number Of Blocks
+ 4,
+ // Moving Blocks
+ {
+ {4,false,30},
+ },
+ // Number Of Moving blocks
+ 1,
+ // Initial Position
+ {10,30},
+ // Goal
+ {84,48}
+};
+