Skip to content

a memory game made only using C and SDL2 Library

License

Notifications You must be signed in to change notification settings

Abdo30004/Path-Ball

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path Ball Game

Description

This is a game project for the University of Technology and Sciences Houari Boumediene (USTHB) in Algiers, Algeria. It's a 2D puzzle game made with SDL2 and C.

Game Description

In Path Ball, your objective is to remember the positions of various bumpers before they disappear. This task extends beyond simple memorization, requiring players to mentally simulate how the ball will rebound off these bumpers and predict its subsequent trajectory. This challenge not only tests your ability to retain information but also demands the analytical skill to interpret and anticipate the ball's movements, making it a cognitive exercise that involves both memory and strategic reasoning.

How to play

The game is played with the mouse or keyboard. The player has to remember the position of the bumpers for a few seconds (3s default), then the bumpers disappear and the ball start position is shown. The player has to predict the path and the final position of the ball and click on it. The player has 3 lives; if he misses 3 times, he loses a level; if he wins 3 times in a row, he goes to the next level; losing in the first level means game over; winning the last level (10) means winning the game.

Game Modes

  • Player Mode : The normal mode of the game , the player has to predict the path of the ball.
  • Machine Auto Mode : The machine sets the bumpers and predicts the path of the ball and selects the final position.
  • Machine Manual Mode : The Player sets the bumpers and chooses the start position of the ball and the machine predicts the path and selects the final position.

Note : In the machine modes,the machine never misses. Besides, the machine doesn't have access to the logic of the game (the game matrix), it only has access to the screen. It reads the pixels of the screen to get the positions of the bumpers and the start position of the ball and builds a different matrix to simulate the game.

Folder Structure

  • src/ : Contains all the source files.
  • include/ : Contains all the header files.
  • assets/ : Contains all the assets used in the game.
  • bin/ : Contains the executable file (and the dlls for windows) after building the project.
  • Makefile : Makefile for the project (compile, clean, etc...)
  • archive/ : Contains old files (not used anymore) that represent the old version of the game.

Files Description

  • main.c : The main file of the game that contains the main loop.
  • logic.c : Contains the game logic (matrix manipulation, ball movement, score, etc...)
  • draw.c : Contains the drawing functions (draw Grid, draw main menu, etc...)
  • render.c : Contains the rendering functions (rendering the main menu, the game mode ...)
  • handlers.c : Contains the event handling functions (keyboard, mouse, etc...)
  • util.c : Contains the utility functions (formatting, etc...)

Each file has a corresponding header file in the include/ folder except for main.c, header files are named the same as the source file but with a .h extension and contain the macros (constants), the structures and type definitions, the function prototypes with documentation and the includes.

Dependencies List

  • SDL2 : The main library used for the game. install
  • SDL2_image : Used for loading images. install
  • SDL2_ttf : Used for rendering text. install
  • SDL2_mixer : Used for playing sounds. install
  • mingw32 (gcc) : C language compiler. install

How to build

  • Run make in the root directory of the project. if it didn't work, try to run mingw32-make instead.

  • For windows, don't forget to add the dlls to the bin/ folder (not included in the repository).

Authors

-Yahiaoui Abderrahmane : GitHub / Discord

-Oubyi Mohamed Yacine : GitHub / Discord

Screenshots

Main Menu

MainMenu

Main Game

MainGame

Game Over

GameOver

Top Players

TopPlayers

License

MIT

About

a memory game made only using C and SDL2 Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.5%
  • Makefile 1.5%