Team Members
- Nikhil Vyas - 130050023
- Utkarsh Mall - 130050037
Objective
- Program allows 2 users to play a game of Carrom.
Input
- Through Canvas- Input through mouse on initCanvas which provides direction and speed to goti.
- Through Terminal- At starting of game name of players is taken as input through terminal.
Output
- Canvas Output The output(game) comes on initCanvas.
- File Output File output goes to a log file (Previous_game.txt) which consists information about each turn of previous game.
Procedure
- Enter names of the two players.
- Set the striker by first click.
- By second click give power and direction to striker.
- Power(speed) is directly proportional to distance of click from position of striker.
Major Classes
- Velocity : Stores the x and y components of velocity.
- Acceleration : Stores the x and y components of acceleration.
- Goti : Stores the attributes of goti its circle,velocity,acceleration and address of next goti.
- List : Stores address of the starting goti.
Major Function
- structure : this creates the board of the game.
- set : Theese functions are used to set values for velocity and acceleration.
- time_till* : These functions give time till a particular event. Example - time_till_collision_with_wall.
- min : This function takes input from the several time_till function and return the value of time till the first event.
- collision_with* : These functions Change the velocity according to the type of collision. Example - collision_with_wall.
- Function of goti and list class. Example - stop(goti),add(list).
Algorithm
- Two lists l_mov,l_stat are created l_mov contains all moving gotis l_stat contains all stationary gotis.
- min function is called which takes input from : time_till_stop,time_till_collision_with_wall, time_till_collision_with_ball_stationary, time_till_collision_with_ball_moving, time_till_going_in_the_pocket for every goti.
- From these inputs it returns the type of event and the minimum time and goti corresponding to event of minimum time are stored through pointers p and q.
- The gotis are moved till the minimum time returned by min function.
- The corresponding changes to the velocity and acceleration of gotis (in cases of collision) and changes to l_mov and l_stat (in cases like stopping) are applied using the type of event and pointers (p and q).
- The turn is considered to be at end when no goti is moving.
- This procedure is repeated till all the gotis go in the pockets.
Image
A Still of Game
How To Run The Code
- Configure the simplecpp folder given in the folder (project will not run on default simplecpp due to lack of getX and getY functions).
- Compile the carrom.cpp file using the above mentioned simplecpp.
- Execute a.out using terminal.