Skip to content

soham-c04/SAHAS-Arcade

Repository files navigation

SAHAS Arcade

This Project is done by members:

  • Aditya Dhananjay Singh
  • Atharva Atul Penkar
  • Harshil Singh
  • Kumar Snehal
  • Soham Chakraborty

This is a multiplayer - online and offline game.

The project is a code written in C++ language which contains an arcade consisting of three games - 2048, Air Hockey and Snake. It uses graphics.h library to print visuals in a graphics window. All coding was done in DevC++ IDE and code editor and the compiler used was TDM-GCC 4.9.2 32-bit Release. A resources .zip folder is also included which contains images used in the program. All the images are made by the team members themselves.

Link to Original Project

The concepts used in the program are:

Double Buffering to reduce flickering when printing objects.

Division of one main.cpp file into multiple .h and .cpp files for each individual game.
Air_Hockey is further divided into multiple .h and .cpp for online and offline versions of the game.

Air Hockey:

  • Object-Oriented Programming
    • Encapsulation and Abstraction - Usage of structs and classes for different components of game such as Ball, Striker and Goal.
    • Polymorphism - Functional overloading of sendData() in client.cpp.
  • Elastic Collision of bodies (along with InElastic Coefficient of Restitution and friction used in Soccer Stars).
  • Counting of score when player scores goal, along with slowed Goal scoring animation.
  • Simultaneous keyboard inputs from both players via non-blocking functions (along with mouse inputs in Soccer Stars).
  • Time counter.
  • Resume, reset, settings and exit to main menu functionality.

Online:

  • Information transmission using Socket Programming in C++.
  • Authoritative server based approach.
  • Syncrhonization of all Objects for both players.
  • Usage of delimiters ('$') for information sent from server to clients, to detect multiple overlapped received messages on client side.
  • Threading
    • Server - One thread for each ongoing game between clients, and deletion of thread after game is finished.
    • Client - Main thread which prints the visuals onto the screen and a child thread for receiving messages sent by server and updating all the Objects. This is necessary because otherwise the client gets overloaded from server messages and unable to process them, resulting in game crashes.
  • Pairing up of unpaired opponents who are waiting to get paired.

2048:

  • Array Rotation
  • Addition of similar elements only
  • Winning and losing conditions
  • Reset and exit to main menu functionality

Snake Game

  • Movement of snake
  • Checking collision of snake with boundary
  • Counting and increasing length of snake when it eats food
  • Exit to main menu functionality

How to play:-

Note:- Make sure to have the resources folder in the same directory as "SAHAS-Arcade.exe".

Air Hockey

  • The controls for the player on the left side are - 'W', 'A', 'S', 'D'. The right side player controls are - UP, DOWN, LEFT and RIGHT arrow keys.
  • The aim is to score more goals than your opponent.
  • The game ends after 90-sec and whoever scores more goals in that time wins, or ends in a draw.

Online:-

  1. Start server.exe and enter port_no for server.
  2. Set the Gamemode to Online.
  3. Enter ip of server in which server.exe was started, then enter the port no.
  4. Wait for another player to join and matchmaking.

Main Menu:

Choose gamemode - Online or Offline or Quit to Home Screen.

Settings:

Choose the colors of Strikers.

Pause Screen (only for Offline mode):

  • Pressing Escape between the game will pause the game and a dialogue box with menu options will be shown.
  • Pressing Escape again or pressing enter on resume option will resume the game again.
  • Options can be switched using arrow keys and to choose an option Enter Key is pressed.
  • Reset - restarts the whole game including goals, initial position of strikers, ball and Timer.
  • Settings - open the settings tab to change colors in between the game.
  • Quit - goes back to the Main Menu page.


2048

  • The controls are - UP, DOWN, LEFT and RIGHT arrow keys.
  • Pressing an ARROW key moves all the numbers to that side of board and then generates a new random number.
  • Rules are same as that of Original 2048.

Pause Screen:

  • Pressing Escape between the game will pause the game and a dialogue box with menu options will be shown.
  • Pressing Escape again will resume the game again.
  • Options can be switched using arrow keys and to choose an option Enter Key is pressed.
  • Reset - restarts the whole game score and board.
  • Quit - goes back Home Screen.


End Screen:

  • If you manage to make the number 2048 then you win and a Menu to continue or not appears.
  • If all squares are occupied before making the number 2048 and there are no more moves left then option appears to Reset or Quit to Home screen.


Snake Game

  • The controls are - UP, DOWN, LEFT and RIGHT arrow keys.
  • The aim is to score as many points by increasing the length of your snake.
  • The game ends if you bump into yourself or by pressing Escape.



Gameplay

Home Screen


Air Hockey

Offline





Online

2048


Snake Game



$$ - THE \space \space END - $$

About

This was a group project, where a set of games are developed using C,C++ and library graphics.h

Topics

Resources

License

Stars

Watchers

Forks

Contributors