Karate Handheld Game Complete

posted 4 Dec 2016, 12:41 by Andy Lakin-Hall   [ updated 10 Dec 2016, 05:10 ]

A little while ago I partially completed the construction of my first serious Arduino project - to build a handheld electronic game like one I had when I was a kid.

This was Black Belt, by Action GT. It was brilliant. The LEDs lit up to show the attacks. You moved the arms and legs on the little man to block the attacks. The sounds were little synthesised screams, and when you missed an attack it laughed at you, and then returned your score by flashing the lights.

I remember it fitted neatly into my blazer pocket, and playing with it on the bus and on the walk to school. I loved it.

Sadly it started to malfunction. The contacts beneath the arms became worn away, and eventually the game became useless. (Sad face)

Fast forward several decades, and I start to find out about programmable microcontrollers, including Arduino. Eventually I learned enough about Arduino to attempt building my own version of Black Belt.


If you trawl back through this blog, you'll see all the steps in the build for this project. But this is the last. It's taken just under a year to complete the project. I was introduced to the Orange Pip Arduino Clone at the BETT exhibition in January 2016 and now it's early December.

I'm so glad I kept a blog of what I did. I've not a had a chance to fiddle with this for a long time, so I've forgotten everything about the project. I've got my first RaspberryJam event as an exhibitor next weekend, and I've got a few days free to go through my bits and pieces. I'd been meaning to tidy up the front panel properly. It's just a laser print with a fronting of clear sticky plastic. I'm quite pleased with the outcome.The insert I had previously made looked rather tatty where I'd bodged the mounting holes, and it looked grotty behind the box lid. 

The box itself is a bit bigger than I had originally planned, but this is what I could find in the local Pound Shop, and it does open up easily to see all the electronics inside.

Okay, if I had access to a 3D printer, I'd have made my own case, and made movable arms or something. But I'm still pleased with what I've made. Really happy.

Update - Little Tune at the start

I decided to add a little tune that will play when the start button is pressed.

I used Scratch to compose the sequence of tones - E, D, B, D, E, E, D, E. It sounds faintly oriental.

I found an Arduino reference that converts notes to the number codes required;

Note Code
B 123
D 294
E 330

Then using other sounds I've previously used in the game, I created the following function;

// play a tune

void play_tune() {
  tone(3, 330, 250); //E
  delay(100);
  tone(3, 294, 250); //D
  delay(100);
  tone(3, 123, 250); //B
  delay(100);
  tone(3, 294, 250); //D
  delay(100);
  tone(3, 330, 250); //E
  delay(100);
  tone(3, 330, 250); //E
  delay(100);
  tone(3, 294, 250); //D
  delay(100);
  tone(3, 330, 500); //E
  delay(1000);
}

I included the delay(1000); so there'd be a second delay after the tune plays before the game starts.

Then I hunted through the main loop until I found the section that detects when the red button is pressed;

    //The BUTTON has been pressed
    //Start the game
    GameOn = 1;
    Score = 0;
    interval = 3000;
    lastMillis = millis();
    play_tune();
    displayBinary(random(14)+1);  //set the LEDs to a random number

The command play_tune(); fits in just before the first random number displayed on the LEDs.

Game in Action

Here's a video of my game working.


ċ
Karate3.ino
(7k)
Andy Lakin-Hall,
10 Dec 2016, 05:28
Comments