diff options
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | cube.o | bin | 22112 -> 23088 bytes | |||
| -rwxr-xr-x | example/a.out | bin | 0 -> 49752 bytes | |||
| -rwxr-xr-x | example/compile.sh | 1 | ||||
| -rw-r--r-- | example/example.cpp | 34 | ||||
| -rw-r--r-- | example/example.o | bin | 0 -> 33856 bytes |
6 files changed, 45 insertions, 2 deletions
| @@ -4,7 +4,7 @@ A simple set of basic routines for working with a 3x3x3 Rubik's Cube. | |||
| 4 | 4 | ||
| 5 | ## How to use CubeCore | 5 | ## How to use CubeCore |
| 6 | 6 | ||
| 7 | (More details coming soon) | 7 | See the example in `example/` for details. |
| 8 | 8 | ||
| 9 | 0. Requirements: a C99 compiler (e.g. GCC) | 9 | 0. Requirements: a C99 compiler (e.g. GCC) |
| 10 | 10 | ||
| @@ -15,12 +15,20 @@ $ make | |||
| 15 | $ make test # optional | 15 | $ make test # optional |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | 2. Include in your C or C++ project | 18 | 2. Include in your C project |
| 19 | 19 | ||
| 20 | ``` | 20 | ``` |
| 21 | #include "cube.h" | 21 | #include "cube.h" |
| 22 | ``` | 22 | ``` |
| 23 | 23 | ||
| 24 | or in your C++ project | ||
| 25 | |||
| 26 | ``` | ||
| 27 | extern "C" { | ||
| 28 | #include "cube.h" | ||
| 29 | } | ||
| 30 | ``` | ||
| 31 | |||
| 24 | 3. Compile including the `cube.o` file | 32 | 3. Compile including the `cube.o` file |
| 25 | 33 | ||
| 26 | ``` | 34 | ``` |
| Binary files differ | |||
diff --git a/example/a.out b/example/a.out new file mode 100755 index 0000000..ef2babe --- /dev/null +++ b/example/a.out | |||
| Binary files differ | |||
diff --git a/example/compile.sh b/example/compile.sh new file mode 100755 index 0000000..4ce3bd2 --- /dev/null +++ b/example/compile.sh | |||
| @@ -0,0 +1 @@ | |||
| g++ example.cpp ../cube.o | |||
diff --git a/example/example.cpp b/example/example.cpp new file mode 100644 index 0000000..60c998f --- /dev/null +++ b/example/example.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #include <cinttypes> | ||
| 2 | #include <iostream> | ||
| 3 | #include <vector> | ||
| 4 | |||
| 5 | extern "C" { | ||
| 6 | #include "../cube.h" | ||
| 7 | } | ||
| 8 | |||
| 9 | cube_t apply_alg(cube_t cube, std::vector<move_t> *moves) { | ||
| 10 | auto ret = cube; | ||
| 11 | |||
| 12 | for (auto m : *moves) | ||
| 13 | ret = cube_move(ret, m); | ||
| 14 | |||
| 15 | return ret; | ||
| 16 | } | ||
| 17 | |||
| 18 | int main() { | ||
| 19 | auto cube = cube_new(); | ||
| 20 | auto moves = new std::vector<move_t> { R, U, R3, U3 }; | ||
| 21 | char cstr[500]; | ||
| 22 | |||
| 23 | std::cout << "The solved cube looks like this in H48 notation:\n"; | ||
| 24 | cube_write((char *)"H48", cube, cstr); | ||
| 25 | std::string solvedstr(cstr); | ||
| 26 | std::cout << solvedstr << "\n"; | ||
| 27 | std::cout << "After a sexy move it looks like this:\n"; | ||
| 28 | cube = apply_alg(cube, moves); | ||
| 29 | cube_write((char *)"H48", cube, cstr); | ||
| 30 | std::string sexystr(cstr); | ||
| 31 | std::cout << sexystr << "\n"; | ||
| 32 | |||
| 33 | return 0; | ||
| 34 | } | ||
diff --git a/example/example.o b/example/example.o new file mode 100644 index 0000000..af95a15 --- /dev/null +++ b/example/example.o | |||
| Binary files differ | |||
