Project information
- Date: December 27, 2022 – January 21, 2023
- Languages: Python, C++ (Arduino)
- Libraries: PyGame, pySerial, csv
- Hardware: MPU6050 Gyroscope + Arduino
- GitHub: zkarim28/i-kiwi-ki
- Demo: YouTube
Python
PyGame
Arduino
C++
MPU6050
Serial
Game Dev
Summary
i-kiwi-ki is a survival game built with Python and PyGame where players throw kiwis at randomly spawning enemies to earn points and survive as long as possible. The twist: the player is controlled entirely by physically tilting a handheld gyroscope controller — greater tilt in a direction adds velocity over time, mimicking inertial physics.
Controller Design
The controller uses an MPU6050 gyroscope/accelerometer module connected to an Arduino. A C++ Arduino sketch continuously reads orientation data and streams it over serial at a fixed baud rate. On the Python side, the pySerial library reads the incoming data stream and maps tilt angles to player velocity increments each game tick.
Software Architecture
- Real-time serial parsing on a dedicated thread, decoupled from the game loop
- Thread-safe data structures to pass controller state from the serial thread to the game thread without blocking
- Persistent leaderboard written to CSV; loaded and displayed on the leaderboard screen
- Calibration screen at startup to zero the gyroscope against the user's resting tilt