Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functional #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ you've made yourself!
| 15. | [**WhackAMole**](./games/015_WhackAMole) <br><sup>CleverPet&nbsp;<[email protected]></sup>|[![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) <br><sup>Michael Gschwandtner&nbsp;<mgschwan -at- gmail.com></sup> | [![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) <br><sup>Jelmer&nbsp;Tiete&nbsp;<[email protected]></sup> | [![Install Symon](./docs/images/install.png)][Symon] | CleverPet's take on the classic Simon game! | ![]() |
| 18. | [**OddOneOutRepeated**](./games/018_OddOneOutRepeated) <br><sup>Omar&nbsp;Khan&nbsp;<[email protected]></sup> | [![Install OddOneOutRepeated](./docs/images/install.png)][OddOneOutRepeated] | An example using an alternative API to create a game | ![]() |

--------

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions games/018_OddOneOutRepeated/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name=OddOneOutRepeated
dependencies.hackerpet=0.2.3
dependencies.hackerpet-functional=0.1.0
50 changes: 50 additions & 0 deletions games/018_OddOneOutRepeated/src/OddOneOutRepeated.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <hackerpet-functional>

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 = []() {},
});
}