π Upvote for my product hunt!
Randomly connect to a player around the world and challenge him/her. Remember not to blink!
For full version of demo video, click here.
.
βββ backend
β βββ __init__.py
β βββ detect.py
β βββ shape_predictor_68_face_landmarks.dat (detect model)
βββ package.json
βββ requirements.txt
βββ server.py
βββ src
β βββ app.jsx
β βββ index.js
β βββ play.jsx
β βββ start.jsx
βββ static
β βββ bundle.js
βββ templates
β βββ index.html
βββ webpack.config.js
We use react
as our frontend framework, and use peerjs
to communicate between clients. At backend, we use flask
to host the server. For connection between clients and server, we use socketio
to implement real-time data transfer.
We use the notion of Finite State Machine to design our game state. The circle is the state. The text in the top of each box is the event causing state transition, and the text in the bottom of each box is the action taken when event occurs. The logic looks quite simple here, but it is not that easy to implement. For more detail you can check play.jsx or server.py.
I spent lots of time formatting my code and writing comments to make it as readable as possible. Hope you enjoy π
git clone git@github.com:ByronHsu/Never-Blink.git
# Frontend
npm install
# Backend
pip install -r requirements.txt
# Build frontend files
npm run build
# Run server
npm run start
Every time you changed your code, you should run the above command again. We do not support hot module replacement now.
Goto https://0.0.0.0:3000
0.0.0.0:3000
does not work, remember to add https
.