Javair RatliffShiv DallaNeil Shah
Published

Blinky Bird

Mind-controlled Flappy Bird clone Using Unity and Muse Brain Sensor

ExpertWork in progress70
Blinky Bird

Things used in this project

Hardware components

Muse Brain Sensor
×1

Code

Python Muse Code

Python
Requires SendKeys 0.3, and PyOSC
import OSC
from OSC1 import OSCServer
import sys
from time import sleep
import SendKeys

server = OSCServer( ("localhost", 5002) )
server.timeout = 0
run = True

# this method of reporting timeouts only works by convention
# that before calling handle_request() field .timed_out is 
# set to False
def handle_timeout(self):
    self.timed_out = True

def user_callback(path, tags, args, source):
    # which user will be determined by path:
    # we just throw away all slashes and join together what's left
    user = ''.join(path.split("/"))
    # tags will contain 'fff'
    # args is a OSCMessage with data
    # source is where the message came from (in case you need to reply)
    if args[0] == 1:
        SendKeys.SendKeys("K")
    

# funny python's way to add a method to an instance of a class
import types
server.handle_timeout = types.MethodType(handle_timeout, server)

server.addMsgHandler( "/muse/elements/blink", user_callback )

def each_frame():
    server.timed_out = False
    while not server.timed_out:
        server.handle_request()

# simulate a "game engine"
while run:
    each_frame()

server.close()

Credits

Javair Ratliff
4 projects • 3 followers
Contact
Shiv Dalla
4 projects • 1 follower
University of Pennsylvania '18 | Bioengineering University of Pennsylvania '19 | Robotics University of Kansas School of Medicine '23 | MD
Contact
Neil Shah
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.