Giter VIP home page Giter VIP logo

pong's Introduction

Pong

screenshot

This is a basic canvas implementation of Atari's popular game, first released in 1972.

There are two releases: the first one (v1.0) is very lightweight (around 200 lines of code), no sound, no AI and no proper ball reflection with vectors.

The second release (that is in master branch) has a lot more stuff, check it out.

In both cases, there are no dependencies from external libraries (yes, this means the game has been made from scratch).

How to play

You can play a demo here.

If you want to play it locally, fork or clone the repository as usual. It shouldn't need any server to run (just open index.html). However in some cases (e.g. using Chrome) it might not work if you don't use a web server.

Controls

Start the game with spacebar.

Player 1

  • up: w
  • down: s

Player 2

  • up: arrow up
  • down: arrow down

Implementation details

The first implementation (v1.0) is simpler, but you don't have much control over the ball.

In the latter implementation I simulated a curved paddle by varying the normal vector of the paddle's surface. This allows the players to change the ball's movement angle by intercepting the ball in movement to get a steeper or shallower reflection angle.

The ball's collision is obviously perfectly elastic, which means all of the kinetic energy in a collision will get transferred, and the game speed will always be the same.

License

Licensed under the WTFPL license.


I would like to thank Matt Hackett for his tutorial on how to make a simple HTML5 canvas game; I've learned a lot.

pong's People

Contributors

simonewebdesign avatar nicky1525 avatar

Watchers

Harvey Sanders avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.