• Stars
    star
    897
  • Rank 50,907 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ‘€Blink and lose.

Never-Blink

1. πŸŽ‰ Introduction

πŸ™Œ 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.

2. πŸ“œ Implementation

1. Project structure

.
β”œβ”€β”€ 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.

2. Game State

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.

3. πŸ’» Development

I spent lots of time formatting my code and writing comments to make it as readable as possible. Hope you enjoy 😊

  1. Clone this repo.
git clone [email protected]:ByronHsu/Never-Blink.git
  1. Install the packages
# Frontend
npm install
# Backend
pip install -r requirements.txt
  1. Build and Run
# 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.

  1. Start and Enjoy

Goto https://0.0.0.0:3000

0.0.0.0:3000 does not work, remember to add https.

4. 🚧 Problem

  1. Because the detector is too slow and weak, we can not endure too many clients. Therefore, we do not deploy it to a public server now. We plan to train a robust and fast model in the future.
  2. When restarting, the old media connection listener will be called again. So we remove restart temporarily.

5. πŸ“– Reference

  1. Environment setup: https://github.com/rwieruch/minimal-react-webpack-babel-setup
  2. Simple P2P WebRTC package: https://github.com/peers/peerjs
  3. Socket-io: https://socket.io/docs/client-api/
  4. Flask-socketio: https://flask-socketio.readthedocs.io/en/latest/
  5. Blink detector: https://github.com/dilawar/eye-blink-detector
  6. Material UI: https://material-ui.com/

6. πŸ—žοΈ License

MIT Licensed

More Repositories

1

life-commit

πŸƒπŸ“† Life as a git. Commit on your life.
JavaScript
946
star
2

AAG-Visualizer

πŸŒ† πŸ™ πŸŒƒ Viz.js Graphviz - An Elegant Visualizer for And-Inverter Graph
JavaScript
103
star
3

FEGAN

Self-Supervised Deep Learning for Fisheye Image Rectification (pytorch implementation).
Python
39
star
4

FlyteGPT

πŸ¦…πŸ”— Building FlyteGPT on Flyte with LangChain
Python
28
star
5

Foop

πŸ’»πŸ›A For-loop-like debugging GAME
JavaScript
16
star
6

FRAIGs

C++ implementation of FRAIGs. Won the 1st place in 2018 Cadence-sponsored contest in NTU DSnP.
C++
7
star
7

RGB-Conditional-GAN-on-Anime-dataset

Applied RGB as constraint, and generate anime characters with any color
Python
4
star
8

Parallel-Computing

108-1 Parallel Computing Programming Assignments
C
4
star
9

leetcode

leetcode practice
Python
3
star
10

PRF-BERT-NTU-Course-Query-System

2019 DSP Final - A smarter course query system.
Python
3
star
11

losEEr.io

For 2018 NTUEE_WEEK. Inspired by slither.io.
JavaScript
3
star
12

Single-Cycle-MIPS-CPU

2019 NTUEE Computer Architecture Final Project
Verilog
3
star
13

Question-Answering

NTU NLP hw4
Python
2
star
14

Computer_Architecture

108-1 NTUEE CA program assignment
Verilog
2
star
15

JSNote

πŸ“šπŸ“š Try Everything with Javascript
2
star
16

tensorboard-k8s

Smarty
1
star
17

ds-100-final

Jupyter Notebook
1
star
18

submarine-dev

Share some helpful development-only files.
1
star
19

CV

TeX
1
star
20

GAN-template

My simple gan template
Python
1
star
21

GithubAction

1
star
22

CUDA-GEMM

Makefile
1
star
23

java-fullstack-practice

Follow the steps-by-steps tutorial on Udemy course - "Java - ambitious start. Create a real web app!" to build a mini project
Java
1
star
24

PYNote

Learning python
Python
1
star
25

leetcode-artifacts

1
star
26

MIT-6.824

Go
1
star
27

Wenyan-CTF

CSS
1
star
28

nmlab_final

Python
1
star
29

CMU15-445

https://15445.courses.cs.cmu.edu/fall2019/
Shell
1
star