Skip to content
Vicente Adolfo Bolea Sánchez edited this page Sep 8, 2011 · 4 revisions

Table of Contents

EasyPong

Easypong is a PingPong game wrotte in C with NCURSES lib. I did it when i was in my first year of my major. So maybe is too simple. The reason because i did this repository is to try github. But if you want to help me to make a better code, i'll be glad.

How to compile

You maybe have to install ncurses library. So to install tip:

 sudo apt-get install libncurses5-dev 
Go to its directory and tip:
 cc pong.c -lncurses -o pong 
Then:
 ./pong 

How it works

Var's setting

Firstly i used a struct like a class, so the struct called "objeto" have 3 members:

  • Struct objeto:
    • Member x-coordenada called 'x'
    • Member y-coordenada called 'y'
    • Member counter of puntuation called 'c'
    • Member move-vertical called 'movver'
    • Member move-horizontal called 'movhor'
And is also four var of objetos:
  • objeto's var
    • First stick called 'b1
    • Second stick called 'b2'
    • The ball called 'b'
    • The screen called 'scr'

Code's Flow

There is 3 blocks or parts:

  • Setting the structur objeto and diferents functions.
  • Starting part:
    • I declare vars in the first line
    • Start the screen and NCURSES setting
    • I set all the var
  • Principal loop
    • Engine function: It check when the ball is in the edge and is make the game rules
    • Keyboard control
    • Print in the screen
Clone this wiki locally