diff --git a/README.md b/README.md index 0d3a21a..5387787 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ you've made yourself! | 15. | [**WhackAMole**](./games/015_WhackAMole)
CleverPet |[![Install WhackAMole](./docs/images/install.png)][WhackAMole]| This is a more "active" game for the Hub that challenges your player's "paw-eye" coordination. | ![]() | | 16. | [**ControlPet**](./games/016_ControlPet)
Michael Gschwandtner  | [![Install ControlPet](./docs/images/install.png)][ControlPet] | Remote control app for the hub. Control the hub either via a webinterface or from a python program. Enables rapid prototyping of new ideas and guided learning of the hub | ![]() | | 17. | [**Symon**](./games/017_Symon)
Jelmer Tiete  | [![Install Symon](./docs/images/install.png)][Symon] | CleverPet's take on the classic Simon game! | ![]() | + | 18. | [**OddOneOutRepeated**](./games/018_OddOneOutRepeated)
Omar Khan  | [![Install OddOneOutRepeated](./docs/images/install.png)][OddOneOutRepeated] | An example using an alternative API to create a game | ![]() | -------- diff --git a/games/018_OddOneOutRepeated/README.md b/games/018_OddOneOutRepeated/README.md new file mode 100644 index 0000000..e69de29 diff --git a/games/018_OddOneOutRepeated/project.properties b/games/018_OddOneOutRepeated/project.properties new file mode 100644 index 0000000..a39d2f2 --- /dev/null +++ b/games/018_OddOneOutRepeated/project.properties @@ -0,0 +1,3 @@ +name=OddOneOutRepeated +dependencies.hackerpet=0.2.3 +dependencies.hackerpet-functional=0.1.0 diff --git a/games/018_OddOneOutRepeated/src/OddOneOutRepeated.cpp b/games/018_OddOneOutRepeated/src/OddOneOutRepeated.cpp new file mode 100644 index 0000000..94285cb --- /dev/null +++ b/games/018_OddOneOutRepeated/src/OddOneOutRepeated.cpp @@ -0,0 +1,50 @@ +#include + +void setup() { + hub.Initialize(__FILE__); +} + +int color_a; +int color_b; +int answer; + +void loop() { + hub.Run(20); + + play({ + .wait_after_game = true, + .timeout_ms = 30000, + .loss_timer_ms = 10000, + .colors = { + {90, 00}, + {00, 90}, + {70, 70}, + }, + .rounds_per_game = 3, + .tries_per_game = 2, + .on_round_start = [](unsigned char* colors) { + do { + color_a = random(0, 3); + color_b = random(0, 3); + } + while (color_a == color_b); + answer = random(0, 3); + colors[0] = color_a; + colors[1] = color_a; + colors[2] = color_a; + colors[answer] = color_b; + }, + .periodic_update = [](unsigned char* colors) {}, + .on_touch = [](unsigned char* colors, int pad) { + tries++; + }, + .did_pet_win = [](int pad) { + return pad == answer; + }, + .on_pet_win = []() {}, + .did_pet_lose = [](int pad) { + return pad != answer; + }, + .on_pet_lose = []() {}, + }); +}