Documentation 102

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

CSCI102 Documentation of the project.

BY:
1.Aliaa Nagdy 222000114

2.Anfal Hamada 222000065

3.Eman Mohammed 222000058

4.Radwa Emad 222000092


TIC-TAC-TOE WITH PINGPONG GAME:

Description of idea:

The software consists of 2 games (tic tac toe and ping pong)
combined together whereas the tic tac toe has a button which
leads you to the ping pong game.

TIC TAC TOE:


It is an implementation of this classic game using TKINTER module for the GUI.

This is a multiplayer game on a 3*3 grid. Each player takes a turn to play on empty
squares. They can play “x” or “o” according to their turn. The game ends when
the player gets 3 symbols in a row (horizontal, vertical or diagonal) or all squares
get filled without a winner (tie).

The main part of the code sets up the Tkinter window and widgets. It creates a
3x3 grid of buttons using a nested list, with each button calling the next_turn()
function with its row and column indices as arguments. It also creates labels and
buttons for resetting the game and opening another script. Finally, it starts the
Tkinter event loop to handle user interactions with the window

The code was distributed between two members of the team Aliaa and Eman.

ALIAA NAGDY:

The first function:

 Next_turn (row,column):
This function is called when a player clicks on a grid cell to mark it with their symbol. It
checks if the cell is empty and there is no winner yet, and if so, sets the cell's text to the
current player's symbol. It then checks if the game has been won or tied, and updates
the label at the top of the window to indicate the next player's turn or the winner.

The third function:

 Check_empty_spaces ():
This function counts the number of empty cells on the grid and returns True if there are
any empty cells and False otherwise

-----------------------------------------------------------------------------------------------------------
Eman Yasser:

The second function:

 check_winner():
This function checks if the game has been won by either player. It iterates over the
rows, columns, and diagonals of the grid to check if any three cells contain the same
non-empty symbol. If a winning combination is found, the function changes the
background color of the winning cells to green and returns True. If there are no winning
combinations, the function checks if the board is full (no empty cells), and if so, changes
the background color of allthe cells to red to indicate a tie, and returns the string "tie".
Otherwise, it returns False.

The fourth function ():


 Start_new_game():
This function is called when the "reset" button is clicked. It sets a new random player to
start the game and updates the label to indicate their turn. It then clears the text and
background color of all cells.
The fifth function():
 Another game():
This function is called when the "PING PONG" button is clicked. It attempts to open and
execute another Python script which leads us to the second part of the code which is
the ping pong game done by Radwa and Anfal.

PING PONG GAME:


This code is a Python implementation of the classic arcade game "Pong" using the Turtle graphics
module for the user interface. The code was written by the two members:

Anfal Hamada and Radwa Emad:

The game is played by two players, each controlling a paddle that moves up and down along the side of
the screen. A ball bounces back and forth between the paddles, and the players score points by making
the ball pass their opponent's paddle. The code starts by setting up the Turtle graphics window with a
black background and initializing several Turtle objects to represent the ball, center line, and two
paddles. It also creates a Turtle object to display the score.

The code defines four functions to handle movement of the two paddles: player1_upmovement(),
player1_downmovement(), player2_upmovement(), and player2_downmovement(). These functions are
called when the corresponding keys are pressed (w/s for player 1, up/down arrows for player 2). They
move the corresponding paddle up or down by a fixed amount determined by the speed variable.

The code then sets up event listeners to call these functions when the appropriate keys are pressed.

The main loop of the game is implemented using a while loop that runs indefinitely. On each iteration of
the loop, the window is updated and the ball is moved by a fixed amount in the x and y directions
(determined by the dx and dy variables and the ball_speed variable). The code then checks if the ball has
collided with any of the borders or the paddles, and if so, bounces the ball off the appropriate surface by
reversing the sign of the corresponding dx or dy variable.

If the ball passes either player's paddle and reaches the edge of the screen, the code updates the score,
resets the ball to the center of the screen, and changes the direction of the ball's movement in the x
direction. The score is updated by incrementing the appropriate player's score variable (p1 for player 1,
p2 for player 2), clearing the score display, and writing the updated score to the display.
Finally, the code checks if either paddle has reached the top or bottom of the screen, and if so, resets
the paddle's position to the edge of the screen.

You might also like