This is a game that is controlled using the gesture controls of the UNIHIKER K10.
The game theme is a clone of PAC-MAN.
Code(Github) https://github.com/TKTK360/K10-Pacman
HARDWARE LIST
1 UNIHIKER K10
CODE
DrawCode
drawIndexedMap.h
void drawIndexedmap(UNIHIKER_K10* k10, uint8_t* indexmap, int16_t x, uint16_t y)
{
byte i = 0;
int start_x = 0;
uint32_t color = _palette32[indexmap[0]];
for (byte tmpY = 0; tmpY < 8; tmpY++) {
byte width = 1;
for (byte tmpX = 0; tmpX < 8; tmpX++) {
uint32_t next_color = _palette32[indexmap[++i]];
if ((color != next_color && width >= 1) || tmpX == 7) {
start_x = x + tmpX - width + 1;
k10->canvas->canvasLine(start_x, y + tmpY,
start_x + width, y + tmpY,
color);
color = next_color;
width = 0;
}
width++;
}
}
}
CODE
Control Code
Gyro and Gesture are selectable
k10-pacman.ino
void KeyPadLoop()
{
//------------------------------------------
// Start / Pause
//------------------------------------------
if ((k10.buttonA->isPressed())) {
ClearKeys(); but_A=true; delay(300);
} else if ((k10.buttonB->isPressed())) {
ClearKeys(); but_B=true; delay(300);
} else {
but_B=false;
}
if (but_A || but_B) {
return;
}
//------------------------------------------
// Control
//------------------------------------------
// Gesture
if ((k10.isGesture(TiltForward))) {
ClearKeys(); but_UP=true;
} else if ((k10.isGesture(TiltBack))) {
ClearKeys(); but_DOWN=true;
} else if ((k10.isGesture(TiltLeft))) {
ClearKeys(); but_LEFT=true;
} else if ((k10.isGesture(TiltRight))) {
ClearKeys(); but_RIGHT=true;
}
/*/
// Gyro
float accx = (k10.getAccelerometerX());
float accy = (k10.getAccelerometerY());
bool left = false, right = false, up = false, down = false;
// Left or Right
if (accx < -5) {
left = true;
} else if (5 < accx) {
right = true;
} else if (accy < -5) {
up = true;
} else if (5 < accy) {
down = true;
}
if (up) {
ClearKeys(); but_UP=true;
} else if (down) {
ClearKeys(); but_DOWN=true;
}
if (left) {
if (!(up && down))
ClearKeys();
but_LEFT=true;
} else if (right) {
if (!(up && down))
ClearKeys();
but_RIGHT=true;
}
//*/
}
License 
All Rights
Reserved

0