0% found this document useful (0 votes)
18 views27 pages

Report.01 (1) (AutoRecovered)

Uploaded by

Teena Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views27 pages

Report.01 (1) (AutoRecovered)

Uploaded by

Teena Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Project Based Learning Report

On
“PING PONG GAME IN C LANGUAGE”
In partial fulfillment of requirement for the degree of
Bachelor in Computer Application (B.C.A)
Course Code: CA 23.135
Course Title: C Programming Laboratory

Submitted By:
Esha Gupta (240210)
Rimpi (240215)
Teena Arora (240219)

Department of Computer Science and Engineering


SCHOOL OF ENGINEERING AND TECHNOLOGY
Mody University of Science and Technology Laxmangarh, Distt. Sikar-332311

November,2024

1
CERTIFICATE

It is certified that Esha Gupta, Rimpi, Teena Arora B.C.A.1st Semester student from Computer
Science and Engineering, Mody University, Lakshmangarh, has under gone project-based
learning (PBL) on “Ping Pong Game in C language” for the partial fulfillment towards the
degree of Bachelor of Computer Application (B.C.A.) in Computer Science and Engineering.
They have successfully completed the PBL work for the current semester under my/our
supervision.

Dr. Prateek Bhanti


Ms. Aditi Kajala

Acknowledgement
2
We are deeply thankful to our guide, for his invaluable guidance, encouragement, and
constructive feedback throughout the project. His expertise and suggestions helped us overcome
challenges and improve the project's quality.

We also extend our gratitude to Mody University for providing the necessary resources and
infrastructure to complete this project.

Esha Gupta (240210)

Rimpi (240215)

Teena Arora (240219)

ABSTRACT

3
The "Ping Pong Game" project developed in C language is an interactive and engaging console-
based application that allows users to have fun through a paddle and striking game .The primary
objective of the project is to create a simple yet effective game that challenges players' and help
them to entertain .

The game structure includes a racket where players select answers from a list of options. The
application tracks the number of shots the person has played . The player’s score is displayed at
the end of the game, and a congratulatory message is shown based on the final score.

Table of Contents

4
S. No. TOPICS Page No.

Certificate 2

Acknowledgement 3

Abstract 4

1. Introduction 7-9

1.1 Present System 10-11

1.2 Proposed System 11-12

2. Components Details

2.1 Software and Hardware Details 13

3. Steps Performed

Code 14

4. Result/Discussion/Output

4.1 Result with figures 23-24

5
Conclusion 25

Future Scope 26

References 27

Chapter 1: Introduction

6
1. INTRODUCTION

Ping pong, also known as table tennis, is a fast-paced and exciting sport that combines skill,
strategy, and quick reflexes. Played by two or four players, the game takes place on a rectangular
table divided by a net. Players use small, lightweight paddles to hit a lightweight plastic ball back
and forth, aiming to score points by outmanoeuvring their opponent.

Background:

The origins of ping pong, or table tennis, trace back to the late 19th century in
England, where it began as an indoor adaptation of lawn tennis. Initially, it was a
casual parlor game played by the upper class after dinner. Players used everyday
objects like books as paddles, corks or balls of string as balls, and a row of books
or a net as the divider.

The game quickly evolved, with more structured rules and specialized equipment
emerging. By the 1900s, manufacturers began producing celluloid balls and
paddles with rubber surfaces, which improved gameplay. The term "ping pong"
was trademarked by the Parker Brothers (now Hasbro) in the early 1900s, though
the sport officially adopted "table tennis" as its name in international competitions.

Objective:

The objective of the game is to score points by either forcing your opponent to
miss the ball or make an invalid return. Ping pong can be played recreationally or
competitively, with matches often being thrilling displays of agility, precision, and
tactical thinking.

7
Whether you're a beginner learning the basics or a seasoned pro, ping pong is a
game that can be enjoyed by people of all ages and skill levels. It’s not just about
competition—it’s also about having fun, staying active, and sharpening your hand-
eye coordination.

Significance:

The proposed system aims to:

- Entertainment and Stress relief.

- Cognitive and skill development.

- Enhanced creativity.

- Technological Advancement

Entertainment and Stress Relief :


Computer games offer an immersive escape from daily routines, helping players relax and reduce
stress.

The interactive nature makes gaming a highly engaging form of entertainment.

 Cognitive and Skill Development


Problem-Solving and Strategy: Many games require critical thinking, planning, and decision-
making.

Hand-Eye Coordination: Fast-paced games enhance reflexes and motor skills.

8
Creativity: Games like Minecraft encourage creativity and resource management.

Technological Advancement:
Game development drives innovations in graphics, AI, virtual reality, and augmented reality.

These advancements often benefit other industries, including healthcare, education, and
architecture.

 Therapeutic and Psychological Benefits :


Gamification is used in therapy to help patients with physical rehabilitation, mental health issues,
and learning disabilities.

They improve focus, memory, and resilience.

 Inclusivity and Accessibility :

Computer games create inclusive environments for players with disabilities


through adaptive technology.

They serve as a platform for representation and diversity in character design and
storytelling.

Limitations

1. Limited to single player only.


2. Player has to play with computer.
3. It can be more interactive.

Technical Limitations

9
1. Limited User Interface (UI) Capabilities.

2. Limited Graphics and Sound Support

3. No Support for Multithreading

1.1 PRESENT SYSTEM

The present system of a quiz game typically refers to an existing implementation or version of a
quiz game that is already functional, though it may have certain limitations or opportunities for
improvement. A present system could vary greatly depending on how the game is structured,
what technologies are used, and its features. Below is an outline of the common features and
characteristics of a basic present system of a quiz game.

 System Overview

The present system of a quiz game generally operates on a simple text-based interface. It allows
users to answer a series of questions and provides immediate feedback on their performance. The
system may or may not include additional features such as difficulty selection, time limits, or
score tracking.

 Core Features of Present Quiz Game System

The core features of a typical quiz game system include the following:

a. User Interface
b. Text-based Interface (Console): A simple interface where the user interacts by
typing in answers or selecting options via the keyboard.

10
c. Start Game: The user selects to start the ping pong game, which then presents questions
one by one.
Game Navigation: After ,the user typically presses "Enter" to move to the next round.
Some versions may allow the user to skip or jump between rounds.
Game End: At the end of the game, the system displays the user’s total score, how much
score was obtained at last, and sometimes a summary of their performance.
d. Score and Leaderboard
Final Score: Once the level is started, the system displays the user’s score, which is the
number of correct times they reciprocated the ball with racket out of the total balls
offered.
e. Retry and Exit
f. Replay Option: After the game ends, users are often prompted to try again or quit. They
can choose to restart the game with different settings or categories.
Exit Game: The game provides the option to exit after completing the quiz

1.2 PROPOSED SYSTEM

The ping pong game system can be designed with multiple features, including different
categories, difficulty levels, a time limit for each level , a scoring system, and a
leaderboard. The idea is to make the engaging, competitive, and flexible.
Here’s a breakdown of a proposed design for a ping pong game in C:

1. Features:
 Categories: The game can have different categories such as "attractice interface". The
concept is taken from table tennis game.
 Difficulty Levels: There can be different levels of difficulty (e.g., Easy, Medium, Hard).
 Timer: Each ball will have a time limit to answer.
 Scoring System: The user earns points for each ball hitted.

11
 Leaderboard: Track the highest scores for players.

2. Game Flow:
 Start Screen: Greet the user and let them select the category and difficulty.
 Game Round: The game will begin at 0:00 and the racket will appear and ball will be
thrown on the player to hit.
 Timer: A countdown for hitting each ball (e.g., 10 seconds per ball).
 Leaderboard: A file or array to track the top scores.
 Player Data: Store the current player’s name and score for the session.

4. C Code Example:
Below is a simple implementation of the proposed system. It handles:
 Categories and difficulty levels
 Timer for each question
 Scoring system

Chapter 2 : Components Details

2.1 SOFTWARE DETAILS

12
 Compiler - Turbo C
 Software System – Windows 11

2.2 HARDWARE DETAILS

AMD RYZEN5 5500U APU

512GB Solid State Drive

16 GB SODIMM DDR4 SDRAM

UI Components:

o Welcome Screen, Question Display, Feedback, and Score Display.


 Game Logic Components:

Game Flow, Input Validation.

 Data Management Components:


o Question Bank, Score Tracking, Replay Mechanism.
 Auxiliary Components:
o Randomization, Error Handling.

Each component works together to create a smooth and interactive quiz game experience. The
structure can be easily extended with additional features like difficulty levels, multiple
categories, or a leaderboard system.

Chapter 3: Steps Performed

3.1 FLOWCHART

13
Figure 3.1

3.2 PROCESS

In a ping pong game implemented in C, the steps performed can be broken down into a series of
operations that guide the game flow from start to finish. These steps are logically arranged to

create an interactive, engaging experience for the player.

Steps Performed in a Ping Pong Game:

1. Initialization Phase

Step 1: Display Welcome Message

 Action: The game starts by showing a welcome message to the player. This includes the
rules of the game, instructions, and any relevant details (e.g., how to input answers, time
limits).

14
 Function: displayWelcomeMessage ()

Step 2: Get Player's Name

 Action: The player is prompted to enter their name. This is done to personalize the game
and make the experience more interactive.

 Function: getPlayerName (char *name)

3. Game End Phase

Step 10: Display Final Score

 Action: Once the game is completed , the game calculates the player’s final score (e.g.,
number of correct balls hit out of total balls) and displays it.

 Function: displayFinalScore(int score, int totalballs)

Step 11: Ask Player to Replay (Optional)

 Action: After displaying the final score, the game asks the player if they would like to
play the ping pong game again.

 Function: askReplay()

5. Ending Phase

15
Step 12: Exit or Replay

 Action:

o If the player chooses to replay, the game restarts from the beginning (repeating
the initialization and game loop phases).

o If the player chooses not to replay, the game ends with a message of thankyou.

 Function: If the player selects "No," the game exits with a final message.

 Function: If the player selects "Yes," the game restarts, beginning with the welcome
message and the player’s name prompt.

3.3 CODE
#include <stdio.h>

#include <conio.h>

#include <dos.h>

// Game settings

#define WIDTH 40

16
#define HEIGHT 20

// Ball and paddle positions

int ballX, ballY;

int ballDirX = 1, ballDirY = 1;

int leftPaddleY, rightPaddleY;

int userScore = 0, computerScore = 0;

// Function to move the cursor to a specific position

void gotoxy(int x, int y) {

printf("%c[%d;%df", 0x1B, y, x);

// Function to draw the game area

void draw() {

int i, j;

clrscr(); // Clear the screen

// Draw top wall

for (i = 0; i < WIDTH; i++) printf("-");

printf("\n");

// Draw the game area

for (i = 0; i < HEIGHT; i++) {

for (j = 0; j < WIDTH; j++) {

if (j == 0 || j == WIDTH - 1) {

printf("|"); // Side walls

17
} else if (j == 2 && (i == leftPaddleY || i == leftPaddleY + 1 || i == leftPaddleY + 2)) {

printf("|"); // User paddle

} else if (j == WIDTH - 3 && (i == rightPaddleY || i == rightPaddleY + 1 || i == rightPaddleY + 2)) {

printf("|"); // Computer paddle

} else if (i == ballY && j == ballX) {

printf("O"); // Ball

} else {

printf(" ");

printf("\n");

// Draw bottom wall

for (i = 0; i < WIDTH; i++) printf("-");

printf("\n");

// Display scores

printf("User: %d\tComputer: %d\n", userScore, computerScore);

// Function to update the ball's position

void updateBall() {

ballX += ballDirX;

ballY += ballDirY;

// Bounce off top and bottom walls

if (ballY <= 0 || ballY >= HEIGHT - 1) ballDirY = -ballDirY;

18
// Bounce off paddles

if (ballX == 3 && ballY >= leftPaddleY && ballY <= leftPaddleY + 2) ballDirX = -ballDirX;

if (ballX == WIDTH - 4 && ballY >= rightPaddleY && ballY <= rightPaddleY + 2) ballDirX = -ballDirX;

// Scoring

if (ballX <= 0) {

computerScore++;

ballX = WIDTH / 2;

ballY = HEIGHT / 2;

ballDirX = 1; // Reset direction

if (ballX >= WIDTH - 1) {

userScore++;

ballX = WIDTH / 2;

ballY = HEIGHT / 2;

ballDirX = -1; // Reset direction

// Function to update the user's paddle

void updateUserPaddle() {

if (kbhit()) {

char ch = getch();

// Left paddle: W (up), S (down)

if (ch == 'w' && leftPaddleY > 0) leftPaddleY--;

if (ch == 's' && leftPaddleY < HEIGHT - 3) leftPaddleY++;

19
}

// Function to update the computer's paddle

void updateComputerPaddle() {

// Simple AI: Follow the ball

if (ballY > rightPaddleY + 1 && rightPaddleY < HEIGHT - 3) rightPaddleY++;

else if (ballY < rightPaddleY && rightPaddleY > 0) rightPaddleY--;

// Main function

void main() {

int gameRunning = 1;

// Initialize positions

ballX = WIDTH / 2;

ballY = HEIGHT / 2;

leftPaddleY = HEIGHT / 2 - 1;

rightPaddleY = HEIGHT / 2 - 1;

// Game loop

while (gameRunning) {

draw();

updateBall();

updateUserPaddle();

updateComputerPaddle();

delay(50); // Add delay for smooth gameplay

// End game if either player scores 5 points

20
if (userScore == 5 || computerScore == 5) {

gameRunning = 0;

clrscr();

printf("Game Over!\n");

if (userScore == 5) {

printf("You Win!\n");

} else {

printf("Computer Wins!\n");

21
OUTPUT:

22
23
Chapter 4: Result/Discussion/Output

4.1 // RESULTS WITH FIGURES

The result of a ping pong game typically includes the following elements:

1. Number of Correct Answers: This shows how many questions the player answered correctly.

2. Total Number of Balls: The total count of questions in the quiz.

3. Score Percentage: A percentage calculated by dividing the total balls by the total balls of and
then multiplying by 100

24
Conclusion:

In conclusion, the proposed **Ping Pong game in C** is a fun and entertainment way for users
to test and improve their entertainment quotient. The game is built using basic features of the C
programming language, like arrays, loops, and file handling, making it a great project for
learning programming. Users can get instant feedback on their answers, which helps them learn
and stay motivated. Although the game is text-based and doesn’t have fancy graphics, it is
simple, easy to use, and works well on most computers. The system can easily be expanded with
new features like multiplayer modes, leaderboards, or hints for questions. It also gives
programmers a chance to practice important skills like managing memory, checking user input,
and handling errors. While the game starts in a console window, it can be improved in the future
with a graphical interface or even be made available on the web or mobile devices. Overall, this
ping pong game is a good mix of learning, fun, and programming practice, with plenty of room
to grow and improve.

25
Future Scope:

To further enhance the system's functionality and effectiveness, potential future developments
include:

1. Mobile Application: Develop a mobile application for Android and iOS platforms to
increase accessibility.

2. Integration with social media: Integrate social media platforms for seamless login and
sharing.

3. Online Multiplayer: Introduce real-time multiplayer modes where users can compete
against each other, either in head-to-head battles or as part of a team.

4. Web-Based Game: Making it accessible from any browser without the need for
installation. This would allow the game to reach a much larger audience.

5. Voice-Based Interaction: Integrate voice recognition to allow users to answer questions


using speech instead of typing, adding an interactive and hands-free dimension to the game.

26
References:

 GeeksforGeeks
 Youtube
 Let us C
 Google

27

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy