Code Monkey home page Code Monkey logo

pong_fork's Introduction

pong game emulator

This is a clone of the pong game, a C implementation with ncurses interface.

Screenshot

Technical details

The game main thread acts as a controller, receiving data from three children threads: one for the keyboard input handling, one controlling the ball position and one for the ai moves. Another thread is used as signal listener, handling kill/int/term and terminal resize signals. Signals are blocked during program initialization and then managed with a signal file descriptor and a poll from the kernel. Thread communication is provided with a Unix pipe, while threads are provided by user-level pthread library.

Note that ncurses is not thread safe, so operations on the window must be confined into a critical zone, locked with a mutex.

Note

Note: the program uses a system call to change the keyboard settings for a smooth playing, and previous settings are restored before game exit. System keyboard settings are managed throug xset command, so the game requires to run into a X session.

Build

The game requires gcc with ncurses, pthread, unistd, ioctl and signalfd libraries, and the game must run into a Xorg session. So yes, trying to build and run this on Windows is definitely not a good idea.

You can build the game launching the following command on the project root:

gcc ./pong.c ./support.c -lpthread -lncurses

or simply make.

License

The project is licensed under GPL 3. See LICENSE file for the full license.

pong_fork's People

Contributors

m-pilia avatar livibetter 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.