Skip to content

πŸ“ Simple Pong game on C language for terminal Linux

License

Notifications You must be signed in to change notification settings

FezzMad/Pong-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pong game

Simple Pong game on C language for terminal Linux.

Libraries

Installing the ncurses library in Debian/Ubuntu Linux:

$ sudo apt install ncurses-bin
  • unistd - for the delay between cards in microseconds
  • stdio - for other primitive actions (e. g. printf())

Compilation

Go to the Pong-game folder and enter in the terminal:

$ make

Compiled by Pong_game. Run Pong_game in the terminal:

$ ./Pong_game

Gameplay

To move the left racket, use the keys 'A' and 'Z' ('a' and 'z'), for the right - 'K' and 'M' ('k' and 'm'). To pause the game, you need to press the space bar. To exit the game, you need to press ESC or wait for one of the players to win. In the game you can change the speed using the keys '1' , '2', '3', .. ,'0'.

With standard settings, the game ends when one of the players scores seven points.

Since only one input stream is used, when holding the control keys of the racket or when pressing intensively, the racket can move for some time by "inertia".

glider_emblem

Settings

If you want to change drawing symbols, size of field, control keys or the final score to win, you can do it in constants.h.

Drawing management

#define SCORE_WIN 7
#define RACKET_LEFT ']'
#define RACKET_RIGHT '['
#define FIELD ' '
#define WALL '='
#define BALL 'o'
#define MIDDLE_WALL '|'
#define FRAME '-'
#define Y_MAX 20
#define X_MAX 80

Game management

#define EXIT 27  // ESC
#define PAUSE 32  // SPACE
#define UP_RACKET_LEFT 'A'
#define DOWN_RACKET_LEFT 'Z'
#define UP_RACKET_RIGHT 'K'
#define DOWN_RACKET_RIGHT 'M'

About

πŸ“ Simple Pong game on C language for terminal Linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published