JSFiddle - React, Tailwind, and code Playground

by dimskraft

JavaScript

// -------------------------------------------------------------------------
// PONG.js written by joe.v.greathead at gmail dot com
// -------------------------------------------------------------------------
// VERSION 1.0 alpha (aka first version) +++++++++++++++++++++++++++++++++++
// -------------------------------------------------------------------------
// This library was written to insert a game of 1-player playable PONG into
// any web page without additional work. The only requirement for this
// library is jQuery 1.11.0 (tested) though it likely works with jQuery 1.10
// as well (untested).
// -------------------------------------------------------------------------
// CONTROLS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// -------------------------------------------------------------------------
// SPACE - ause/unpause
// Q - Move blue (P1) paddle up
// A - Move blue (P1) paddle down
// R - Reset game
// ESC - Close game
// -------------------------------------------------------------------------
// COMMANDS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// -------------------------------------------------------------------------
// To open the game window and start a game of pong, call
//     
//     PONG.start()
//
// anytime within or after the document is ready. Example usage:
//
//     $(document).ready(function(){
//         PONG.start();
//     });
//
// -------------------------------------------------------------------------
// BUGS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// -------------------------------------------------------------------------
// There are a couple known bugs.
//  - It's possible to stop the ball by sliding the paddle upwards as the
// ball comes down towards the paddle. I thought I fixed this in a previous
// version, but it seems to have come back.
//  - The AI is version 0.2 alpha and as such, isn't always smooth
// in it's movement.
// 
// Whether or...