A LAN game developed using Java Socket & Multithreading where users can create custom rooms & play simultaneously.
• The unique feature of this project is that it allows multiple pair of players to play game concurrently.
• Game allows the players either to create a virtual game room or to join a virtual game room.
• When player choose to create a game room then system will generate a room which contains a unique name.
• When player choose to join a game room then system will ask for the game room name and once user enters it, he will be entered in that room where he can play against the other player who created that room.
• Once the game will get over, system will destroy that particular game room and then same name room will be available for re-creation.
-
First Run the Server file by writing
java Server
in your command prompt. Your Server has been started and your are good to go. -
Now to play games between multiple players open command prompt in any computer which is in same network as the computer running
Server.java
. Then typejava Client
and Enter the IP address of Server, Which will start the game. Here you have 2 options :- Create Room or Join Room. -
If a person has already created the room then you can join that room OR you can create your own room. If a room with already same name exists the you can not create the room with that name. To join the room you will have to give the name of the room that you want to join.
-
If you have created the room, Your game will not start until someone has joined your room. Once a person has joined your room the game will begin. After the game has been finished the room will be destroyed and name of that room is available.
Here I have used 127.0.0.1 as IP adrress because Server.java was running on the same computer as the Client.java
C:\Users\yashs\Downloads\src-20200728T121143Z-001\src>java Server
Total rooms : 0
Server started
C:\Users\yashs\Downloads\src-20200728T121143Z-001\src>java Client
Enter server IP : 127.0.0.1
Select any one : 1)Create room 2)Join room
1
Please Enter the name of the room :
ROOM1
Waiting for the opponent to join the room
C:\Users\yashs\Downloads\src-20200728T121143Z-001\src>java Client
Enter server IP : 127.0.0.1
Select any one : 1)Create room 2)Join room
2
Please Enter the name of the room :
ROOM2
Enter valid room name
Please Enter the name of the room :
ROOM1