Systems and Network Programming
Systems and Network Programming
Multiplayer Game
Group B3G5
Submitted by: Pratyush Shukla 10103471 Richa Agarwal 10103472 Saarthak Jain 10103474
Acknowledgements Acknowledgements
We take this opportunity to express our profound gratitude and deep regards to our guide , Mr. Adarsh Kumar for his exemplary guidance, monitoring and constant encouragement throughout the course of this thesis. The blessing, help and guidance given by him time to time shall carry us a long way in the journey of life on which we are about to embark.
We were fortunate to have had many excellent colleagues especially seniors, who with their questions and comments contributed much to the clarity and exposition of this project.
Lastly, wed like to thank Mr. Adarsh Kumar Srivastava and the Server Room In charge of JIIT who helped us in the smooth functioning of our project by acknowledging our request for access to certain sites.
Contents
1. Title of Project 2. Abstract 3. Objectives 4. Clear division of project work among group members 5. Background Study and Findings 6. Designing 7. Partial Implementation (code, snapshot etc.,) 8. Testing (of Partially implemented Code) 9. References
Burn up the track while experiencing the speed of super-bikes that have light cycles emitted from them. This is not a bike racing game, but a battle between two teams fighting fiercely to conquer the GRID. This game is well known and associated with the thrilling bike battle of the movie, Tron Legacy. TRON gives you a breath-taking thrilling journey through the GRID with battle tanks and light emitting super bikes. You get to contend with a radical, treacherous arena, where you can easily fall to your death from the roads, which soar into the sky. It is also full of obstacles and problems, meaning you'll have to avoid battle tanks that could knock you into the opponents Light stream or even explode. Add that to the fact that your fellow racers aren't adverse to a few low blows, and you've got your work cut out. If you love bikes and are craving for a bit of real action, TRON should definitely be your next move.
Abstract
The Grid is a vast part of TRON System and is made to provide a platform for unparallel speeds. It is often referred to as The Digital Frontier of Tron. Much of the Grid consists of a flat, dark platform with glowing blue, cyan, or white ribbons of light covering it in a vast latticework. Within the Grid itself lie a number of cities, the most populous being Tron City, a metropolis modeled on a real world city. Light Cycles are vehicles resembling motorcycles that are driven by programs and Users, that are the two teams in the Game. A light cycle completely covers the driver - who is forced into a riding position - with a protective canopy. Each Light Cycle is colored according to the color of the team. On the Grid designed for them, light cycles are incredibly fast when moving, and leave behind a solid jetwall in their wake. With their brakes disabled, this creates a hazard whereby one light cycle could be forced to crash into the jetwall of another, causing the victim to die along with their light cycle. The player must guide a blue Light Cycle in an arena against an opponent, while avoiding the walls and trails (walls of light) left behind by both Light Cycles. The player must maneuver quickly and precisely in order to force opponents to run into walls. The enemy cycles have a fixed behavior pattern for each level: if the player can find it, the opponent can be defeated every time on this level. The opponent teams drivers play dirty and the only way you're going to get through is by using some slick moves to throw them off. Once all the members of the one team are forced to leave the game by any means, the other team wins the game.
Objectives
The project objectives include making of a multi player, cross platform bike game for PC with the following features: Multiple game rooms/servers Cross architecture Cross platform game In game chat facility State synchronization across different game instances 3-D graphics Fuel collection scoring The features yet to be implemented are : Team game Light cycles emitted from bike Battle tanks In-game voice chat
WORK HOURS UNDERTAKEN WORK Client server Around connection, hours photon server week connection, GUI of game, camera adjustment, bike movement GUI of game, Around bike movement, hours chat GUI week creation, chat Connection establishment, scoring system, report
Richa Agarwal
10 High per
Low
Saarthak Jain
Client server Around hours connection, photon server week connection, creation of game rooms, state synchronization, display of senders information in chat
10 High per
Low
Unity game engine: Unity (also called Unity3D) is a cross-platform game engine with a built-in IDE developed by Unity Technologies. It is used to develop video games for web plugins, desktop platforms, consoles and mobile devices, and is utilized by over one million developers. Unity is primarily used to create mobile and web games, but can also deploy games to consoles or the PC. The game engine was developed in C/C++, and is able to support code written in C# or JavaScript.
Exit games: Exit Games is a German venture capital financed company, offering a multiplayer engine for multiplayer games and massively multiplayer online games (MMOGs) on various technological platforms, including mobile, PC and consoles. The core of Exit Games' technology is the network engine and socket server "Exit Games Photon"
Photon Networking Engine: This is a network engine and socket server, the core of Exit Game technology. which allows the development of scalable and robust online games. This is offered as client and server SDKs which include libraries for various platforms - such as Unity, iOS, Android, Flash, Silverlight, MeeGo and more -, code samples and documentation.
Network/Socket Programming: Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network.
8
Client/Server Programming : The clientserver model is an approach to computer network programming developed at Xerox PARC during the 1970s. It is now prevalent in computer networks. Email, the World Wide Web, and network printing all apply the clientserver model. The model assigns one of two roles to the computers in a network: Client or server. A server is a computer system that selectively shares its resources; a client is a computer or computer program that initiates contact with a server in order to make use of a resource. Data, CPUs, printers, and data storage devices are some examples of resources.
Various algorithms studied and used for the complemetion of the project are as under:
RPC Details Remote Procedure Call or RPC is a way of calling a function on a remote machine. This may be a client calling a function on the server, or the server calling a function on some or all clients.
State Synchronization State Synchronization is a method of regularly updating a specific set of data across two or more game instances running on the network.
Network Instantiate A complex subject in networking is ownership of an object and determination of who controls what. Network Instantiation handles this task. Also covered are some
more sophisticated alternatives for situations where you need more control over object ownership.
Master Server The Master Server is like a game lobby where servers can advertise their presence to clients. It can also enable communication from behind a firewall or home network using a technique called NAT punchthrough (with help from a facilitator) to make sure your players can always connect with each other.
10
Designing
11
Partial Implementation
Bikemove.js var wheelFL : WheelCollider; var wheelFR : WheelCollider; var wheelRL : WheelCollider; var wheelRR : WheelCollider; var wheelFLTrans : Transform; var wheelFRTrans : Transform; var wheelRLTrans : Transform; var wheelRRTrans : Transform; var lowestSteerAtSpeed : float = 50; var lowSpeedSteerAngel : float = 10; var highSpeedSteerAngel : float = 1; var decellarationSpeed : float = 30; var maxTorque : float = 50; var currentSpeed : float; var topSpeed : float = 50; var maxReverseSpeed : float = 30; private var braked : boolean = false; var maxBrakeTorque : float = 100; private var mySidewayFriction : float; private var myForwardFriction : float; private var slipSidewayFriction : float; private var slipForwardFriction : float; function Start () { rigidbody.centerOfMass.y = -12.0; rigidbody.centerOfMass.z = 0.5;
12
SetValues(); } var scoretext="Score: 0"; function OnCollisionEnter (col : Collision){ if (col.collider.name == "fueltank"){ Destroy(col.gameObject); score +=10; scoretext="Score: "+score; print("Fuel Picked"); print("Score : "+score); } } function OnGUI() { GUILayout.Label(scoretext); } function SetValues (){ myForwardFriction = wheelRR.forwardFriction.stiffness; mySidewayFriction = wheelRR.sidewaysFriction.stiffness; slipForwardFriction = 0.05;
slipSidewayFriction = 0.085; }
function FixedUpdate () { Controle (); HandBrake(); } function Update(){ wheelFLTrans.Rotate(wheelFL.rpm/6 0*360*Time.deltaTime,0,0); wheelFRTrans.Rotate(wheelFR.rpm/6 0*360*Time.deltaTime,0,0); wheelRLTrans.Rotate(wheelRL.rpm/ 60*360*Time.deltaTime,0,0); wheelRRTrans.Rotate(wheelRR.rpm/ 60*360*Time.deltaTime,0,0); wheelFLTrans.localEulerAngles.y = wheelFL.steerAngle wheelFLTrans.localEulerAngles.z; wheelFRTrans.localEulerAngles.y = wheelFR.steerAngle wheelFRTrans.localEulerAngles.z; WheelPosition(); } function Controle (){ currentSpeed = 2*22/7*wheelRL.radius*wheelRL.rp m*60/1000; currentSpeed = Mathf.Round(currentSpeed);
13
if (currentSpeed < topSpeed && currentSpeed > -maxReverseSpeed && !braked){ wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical"); wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical"); } else { wheelRR.motorTorque =0; wheelRL.motorTorque =0; } if (Input.GetButton("Vertical")==false){ wheelRR.brakeTorque = decellarationSpeed; wheelRL.brakeTorque = decellarationSpeed; } else{ wheelRR.brakeTorque = 0; wheelRL.brakeTorque = 0; } var speedFactor = rigidbody.velocity.magnitude/lowestS teerAtSpeed; var currentSteerAngel = Mathf.Lerp(lowSpeedSteerAngel,10,s peedFactor); currentSteerAngel *= Input.GetAxis("Horizontal"); wheelFL.steerAngle = currentSteerAngel; wheelFR.steerAngle = currentSteerAngel;
} function WheelPosition(){ var hit : RaycastHit; var wheelPos : Vector3; if (Physics.Raycast(wheelFL.transform. position, wheelFL.transform.up,hit,wheelFL.ra dius+wheelFL.suspensionDistance) ){ wheelPos = hit.point+wheelFL.transform.up * wheelFL.radius; } else { wheelPos = wheelFL.transform.position wheelFL.transform.up* wheelFL.suspensionDistance; } wheelFLTrans.position = wheelPos; if (Physics.Raycast(wheelFR.transform. position, wheelFR.transform.up,hit,wheelFR.ra dius+wheelFR.suspensionDistance) ){ wheelPos = hit.point+wheelFR.transform.up * wheelFR.radius; } else { wheelPos = wheelFR.transform.position wheelFR.transform.up* wheelFR.suspensionDistance;
14
} wheelFRTrans.position = wheelPos; if (Physics.Raycast(wheelRL.transform. position, wheelRL.transform.up,hit,wheelRL.ra dius+wheelRL.suspensionDistance) ){ wheelPos = hit.point+wheelRL.transform.up * wheelRL.radius; } else { wheelPos = wheelRL.transform.position wheelRL.transform.up* wheelRL.suspensionDistance; } wheelRLTrans.position = wheelPos; if (Physics.Raycast(wheelRR.transform. position, wheelRR.transform.up,hit,wheelRR.ra dius+wheelRR.suspensionDistance) ){ wheelPos = hit.point+wheelRR.transform.up * wheelRR.radius; } else { wheelPos = wheelRR.transform.position wheelRR.transform.up* wheelRR.suspensionDistance;
} wheelRRTrans.position = wheelPos; } function HandBrake(){ if (Input.GetButton("Jump")){ braked = true; } else{ braked = false; } if (braked){ wheelFR.brakeTorque = maxBrakeTorque; wheelFL.brakeTorque = maxBrakeTorque; wheelRR.motorTorque =0; wheelRL.motorTorque =0; if (rigidbody.velocity.magnitude > 1){ SetSlip(slipForwardFriction ,slipSidewayFriction); } else { SetSlip(1 ,1); } if (currentSpeed < 1 && currentSpeed > -1){ } else { wheelFR.brakeTorque = 0; wheelFL.brakeTorque = 0; SetSlip(myForwardFriction ,mySidewayFriction); } }
15
function SetSlip (currentForwardFriction : float,currentSidewayFriction : float){ wheelRR.forwardFriction.stiffness = currentForwardFriction; wheelRL.forwardFriction.stiffness = currentForwardFriction; wheelRR.sidewaysFriction.stiffness = currentSidewayFriction; wheelRL.sidewaysFriction.stiffness = currentSidewayFriction; }
Game arena:
17
Scoring:
18
Testing
Various types of testing and their applicability for our project are as follows: Requirement testing It is required because it will let us know the needs of the project, which will eventually help us in the better development of project .We have to estimate the time required etc. for the project so that we can start properly with the project. Applicable : Yes Unit testing It is the most important of all testing levels. It will help in finding the bugs during the progress of the project, which is much more economical to fix as compared to that when done after completion of the project. Using it, we can test a code a unit of code for different scenarios as soon as it is developed by the programmer. Applicable: Yes Integration testing Integration testing will be perfomed to verify functional, performance, and reliability requirements placed on major design items. It is required to test if all the components within the group of units interact completely. Applicable: Yes Security testing Security testing covers the security concepts like confidentiality, integrity, authentication, availability, authorization and non-repudiation. We do not need the security testing for our project. Applicable: No Load testing Load testing is normally done by subjecting a computer, peripheral, server, network or application to a work level approaching the limits of its application to measure its capability, we do not require finding out such things as our software does not go to such circumstances. Applicable: No
19
Performance testing Performance testing helps in finding the server response time, performance specifications of the system when the multiple users are using the system. It will help in determining that whether the system meets the performance criteria or not in such a situation. Applicable: Yes Usability testing Usability testing is the process by which the human-computer interaction characteristics of a system are measured, and weaknesses are identified for correction. Applicable: Yes
The black box testing done for the project include checking the overall functionality of the project. Its result is as follows: Speed Test: Serial No. 1 2 3
Note: In case the speed is set to more than 90, the bike achieves a speed at which, if it collides with a wall,it will topple over the wall. Hence, maximum speed is set to 50. Centre of gravity test: Serial No. 1 2 3
Action Bike topples from back Bike is stable Bike topples from front
20
Networking New and only user New user when atleast one player present already No player and 2 players join simultaneously
Action Creates a game room Joins the game room Both create separate game room
Line by line code analysis is done in white box testing. The various testing tools used for complete code analysis and syntactical checking are given below with the test results :
JavaLint Bikemove.js
21
NetworkManager.js
Menu1.js
22
References
23
24
25