UFO Game + Teachable Machine

Original Game: Unidentified Aerial Phenomenon

Original game code: https://editor.p5js.org/hnc247/sketches/0jTM-VlBm

Full-screen mode:https://editor.p5js.org/hnc247/full/0jTM-VlBm

STG game (short for Shoot ’em up)

  • The player controls the UFO with keypresses, left and right to change directions, up to move forward, and space bar to shoot lasers.
  • The player needs to shoots out laser to shatter the obstacles coming from each direction. Each time an asteroid is hit, it breakups into more pieces.
  • A score in green is shown on top each time the player hits the astroids. The red numbers are the amount of damage the UFO takes each time you crash on the asteroids. When the damage reaches 300, the game is over and the UFO explodes. The player has to restart the program to play again.

Teachable Machine

I experimented with machine learning on my previous coding project of a simple UFO game. Instead of keypresses, I used Teachable Machine to train the model to recognize 5 moves, which are forward, right spin, left spin, neutral, and pew(firing laser).

Before incorporating trained moves into the game, I followed the tutorial and exported the code into a file to make sure it works. I was initially making the hands crossed gesture as “pew” or firing laser since it is quicker and easier to switch from “forward” gesture. But the accuracy was so low that I have to change it to a fist gesture. Surprisingly, It still works if I cross my hands to fire lasers, and it is incredibly accurate.

Teachable Machine code: https://editor.p5js.org/hnc247/sketches/s2qOMcaTQ

Teachable Machine Sharable Link: https://teachablemachine.withgoogle.com/models/sOlxCMO7q/

 

UFO Game + Teachable Machine

Final Game code: https://editor.p5js.org/hnc247/sketches/9k2IG56uk

Final Game Full Screen Mode: https://editor.p5js.org/hnc247/full/9k2IG56uk

There’s a bug that the UFO would keep spinning unless I set it back to “neutral”. Also, it moves really slow when I do the “forward” motion.

 

Leave a Reply

Your email address will not be published. Required fields are marked *