What you require is accelerometers. Accelerometers with three and six axes modules have become extremely cheap…every iPhone has this. In reality, it’s possible to accomplish anything you need to do with an app, if it was an iPhone.
An easier version is the spring’s weight that is surrounded by rings electrodes. It is possible to make it using springs made from the retractable ballpoint. A few wires and something similar to an a ball bearing or fishing weight.