January 2019
Intermediate to advanced
236 pages
5h 41m
English
Make a new C++ project and add SFML—which you saw here—so you can draw the bees buzzing. The code with this book has a Bees static library for the algorithm. This is called by a unit test project and a main project named ABC. Make the library first, and feel free to add tests as you go. The tests aren’t shown here.
Start by defining a Coordinate class:
| | struct Coordinate |
| | { |
| | double x; |
| | double y; |
| | }; |
You need a Bee class with a home, current position, a favored food spot, and a role. They start out at home. Add a buzz to drive how far the bees move each time. You’ll fill in the remaining parts to this shortly:
| | class Bee |
| | { |
| | public: |
| | explicit Bee(Role role, ... |
Read now
Unlock full access