How to play on a local network - a detailed guide by experienced players. How to create an online game

Many people wonder how to play pirate on the network, if the licensed game is much easier than it would seem, for this case many programs have been invented that connect players from all over the world together.

In this article, we list the most common programs that players often use. You've probably often heard how to play through Hamachi on the network, and the like. How to play old games online? Utilities for playing on LAN and Internet. A video game with a computer is naturally interesting, but it's even more fun to resist not a bot, but a real person! It is possible that he will make some oversight, not an ordinary step, will surprise you with something. Besides, almost all seasoned players play much more fun and more correct than robots ...

But if with almost all the advanced network video games there are no special problems with the connection, WOW, Tanks, GTA and others do not appear, then with video games a certain number of older ones - almost all players have difficulties. In fact, in this material I will give various types and methods of how you can play games on local network and the web with real people (even in those games in which this is not foreseen and there is nothing, not counting the LAN mode, ie games only on "LAN".

Free VPN to solve exactly your problems, connect remote computers into one virtual network. Radmin VPN is a free and easy-to-use virtual private network (VPN) program. The program allows players to establish a secure and reliable connection between computers over the Internet, as if they were connected through a local network. Source - https: // site /

Evolve is a program for creating a local (LAN) network between gamers using the Internet connection. Improved similarity to Tunngle, significantly better and has more capabilities. The biggest advantage is that you do not need to install anything, the program will do everything for you. Evolve is a program for creating a local (LAN) network between gamers using the Internet connection. Improved similarity to Tunngle, significantly better and has more capabilities.

An application providing a virtual local area network for various computer video games. It is possible to build your own rooms or connect to existing ones. GameRanger modulates a virtual local area network for computer video games: this can be useful for those who are tired of playing alone. To do this, in order to participate in a group video game, you simply need to install this program on your computer. Initially, it was designed for a total of ten game programs, but now it supports more than 600 video games.

It is a tool for creating a virtual personal network (VPN) and managing it between some remote computers. Similarly, you can simulate a 100% encrypted and secure local network, which can be very useful for some video games. one of the most famous tools for creating virtual personal VPN networks. Using this program, you can simply establish an encrypted connection over the Internet between remote computers, simulating a connection over a local network.

A common program that allows you to play various computer games in team mode, team up with players from the whole world. The Garena Plus program is a versatile video game client that allows you to build a local network on top of the world wide Internet. The program is used to launch cooperative video games of various genres, allowing you to simply and quickly find competitors for online battles.

Tunngle is a VPN client software intentionally designed for video games in co-op mode. Because of Tunngle, you can play with your own webmates as if it were a local network. There are many programs on the web designed for co-op video games, but Tunngle is considered the absolute favorite among them, offering far more options than its rivals.

LanGame ++ allows people on various networks to play online games, if such a probability is not available in the video game itself. LanGame ++ is a program with which you can play network games for people present in different networks, and similarly in local networks in different subnets, if there is no such probability in the video game itself. Doesn't ask for a connection to the World Wide Web.

First, install the dependencies. Create a project folder, go to it and run the following code:

Npm init npm install --save express socket.io

To quickly configure the server, it is advisable to use the Express framework, and for processing websockets on the server - the socket.io package. Place the following code in your server.js file:

// Dependencies var express \u003d require ("express"); var http \u003d require ("http"); var path \u003d require ("path"); var socketIO \u003d require ("socket.io"); var app \u003d express (); var server \u003d http.Server (app); var io \u003d socketIO (server); app.set ("port", 5000); app.use ("/ static", express.static (__ dirname + "/ static")); // Routes app.get ("/", function (request, response) (response.sendFile (path.join (__ dirname, "index.html"));)); // Start the server server.listen (5000, function () (console.log ("I'm starting the server on port 5000");));

This is pretty typical code for a Node.js + Express server. It installs dependencies and basic routes for the server. There is only one index.html file and a static folder for this demo application. Create them in the root folder of the project. The index.html file is pretty simple:

Our multiplayer game

Your user interface can contain many more elements, so for larger projects it is better to put the CSS styles in a separate file. For the sake of simplicity, I'll leave the CSS in the HTML code. Note that I have included the socket.io.js script in the code. It will automatically work as part of the socket.io package when the server starts.

Now we need to configure the websockets on the server. At the end of the server.js file add:

// Web socket handler io.on ("connection", function (socket) ());

So far, there are no features in the game, so nothing needs to be added to the websocket handler. For testing, add the following lines to the end of the server.js file:

SetInterval (function () (io.sockets.emit ("message", "hi!");), 1000);

This function will send a message named message and hi content to all connected websockets. Remember to remove this part of the code later as it is for testing purposes only.

In the static folder, create a file called game.js. You can write a short function to log messages from the server to make sure you receive them. In your static / game.js file, add the following:

Var socket \u003d io (); socket.on ("message", function (data) (console.log (data);));

Start the server with the node server.js command and in any browser go to the link http: // localhost: 5000. If you open the developer window (right-click → Inspect), you will see a new message arrive every second:

Typically, socket.emit (name, data) sends a message with the given name and data to the server if the request is from a client, and vice versa if the request is from the server. To get messages for a specific name, use the following command:

Socket.on ("name", function (data) (// the data argument can contain any data to send));

With socket.emit () you can send any message. You can also pass JSON objects, which is very convenient for us. This makes it possible to instantly transfer information in the game from server to client and vice versa, which is the basis of multiplayer games.

Now let the client send some keyboard states. Place the following code at the end of your static / game.js file:

Var movement \u003d (up: false, down: false, left: false, right: false) document.addEventListener ("keydown", function (event) (switch (event.keyCode) (case 65: // A movement.left \u003d true; break; case 87: // W movement.up \u003d true; break; case 68: // D movement.right \u003d true; break; case 83: // S movement.down \u003d true; break;))); document.addEventListener ("keyup", function (event) (switch (event.keyCode) (case 65: // A movement.left \u003d false; break; case 87: // W movement.up \u003d false; break; case 68 : // D movement.right \u003d false; break; case 83: // S movement.down \u003d false; break;)));

This is a standard code that allows you to track the pressing of the W, A, S, D keys. After that, add a message that will notify the server that a new player has entered the game, and create a loop that will inform the server about keystrokes.

Socket.emit ("new player"); setInterval (function () (socket.emit ("movement", movement);), 1000/60);

This part of the code will send information about the state of the client's keyboard to the server 60 times per second. Now it is necessary to register this situation from the server side. Add the following lines to the end of the server.js file:

Var players \u003d (); io.on ("connection", function (socket) (socket.on ("new player", function () (players \u003d (x: 300, y: 300);)); socket.on ("movement", function (data) (var player \u003d players || (); if (data.left) (player.x - \u003d 5;) if (data.up) (player.y - \u003d 5;) if (data.right) ( player.x + \u003d 5;) if (data.down) (player.y + \u003d 5;)));)); setInterval (function () (io.sockets.emit ("state", players);), 1000/60);

Let's take a look at this code. You will store information about all connected users as JSON objects. Since each socket connected to the server has a unique id, the key will represent the socket id of the connected player. The value will be another JSON object containing the x and y coordinates.

When the server receives a message that it has joined new player, it will add a new entry to the player object with the socket id that will be in this message. When the server receives a motion message, it will update the information about the player associated with this socket, if one exists.

io.sockets.emit () is a request that will send message and data to ALL connected sockets. The server will send this state to all connected clients 60 times per second.

At this stage, the client does not do anything with this information yet, so add a handler on the client side that will display data from the server to the Canvas.

Var canvas \u003d document.getElementById ("canvas"); canvas.width \u003d 800; canvas.height \u003d 600; var context \u003d canvas.getContext ("2d"); socket.on ("state", function (players) (context.clearRect (0, 0, 800, 600); context.fillStyle \u003d "green"; for (var id in players) (var player \u003d players; context.beginPath (); context.arc (player.x, player.y, 10, 0, 2 * Math.PI); context.fill ();)));

This code accesses the Canvas id (#canvas) and draws there. Every time a status message is received from the server, the data in the Canvas will be reset and all players will be re-displayed as green circles.

Now every new player will be able to see the status of all connected players on the Canvas. Start the server with the command node server.js and open two windows in the browser. When you click on the link http: // localhost: 5000, you should see something similar:

That's all! If you have any problems, check out the source archive.

Some subtleties

As you develop a more functional game, it makes sense to split your code into multiple files.

These multiplayer games are a great example of the MVC (Model-View-Controller) architecture. All the logical part has to be processed on the server, and all the client has to do is send user input to the server and display the information it receives from the server.

However, this demo project has several drawbacks. The game update is associated with a socket listener. If I wanted to influence the course of the game, I could write the following in the browser console:

While (true) (socket.emit ("movement", (left: true));)

Now, motion data will be sent to the server, depending on the characteristics of the computer, more than 60 times per second. This will result in the player moving incredibly fast. This brings us to the concept of defining an authoritative server.

At no stage should the client control any data on the server. For example, you never need to put code on the server that will allow the client to determine its position / health based on the data that is sent over the socket, since the user can easily spoof the message coming from the socket, as shown above.

When I was creating my first multiplayer game, I wrote the code so that the player could fire when a firing message was sent, which on the client side was associated with a mouse click. A skilled player could take advantage of this by inserting a JavaScript line very similar to the one mentioned above to get a near-unlimited rate of fire.

The best analogy I can give is that clients should only send information about their intentions to the server, which will then be processed and used to change the state of the players if they are valid.

Ideally, both client and server update cycles should be socket-independent. Try to keep game updates outside of the socket.on () block. Otherwise, you can get a lot of weird illogical actions due to the game update being associated with a socket update.

Also, try to avoid code like this:

SetInterval (function () (// code ... player.x + \u003d 5; // code ...), 1000/60);

In this chunk of code, the update of the x coordinate for the player is related to the frame rate of the game. SetInterval () doesn't always guarantee that the interval will be respected, write something like this instead:

Var lastUpdateTime \u003d (new Date ()). GetTime (); setInterval (function () (// code ... var currentTime \u003d (new Date ()). getTime (); var timeDifference \u003d currentTime - lastUpdateTime; player.x + \u003d 5 * timeDifference; lastUpdateTime \u003d currentTime;), 1000 / 60);

It is less elegant, but will provide smoother and more consistent performance. Complicate the demo project and try to make sure that the update is carried out according to the time, not the frame rate. If you don't want to stop there, try to create a physics engine on the server that will control the movements of the players.

You can also choose to remove disabled players from the game. When a socket is disconnected, a disconnect message is automatically sent. It can be written like this:

Io.on ("connection", function (socket) (// event handler ... socket.on ("disconnect", function () (// remove the disconnected player));)); ,

If you want to play on two PCs without using the Internet, instantly transfer files from different devices without USB media, then you need to know how to create a local network between two computers. This technology of connecting two PCs has been used for a long time, even today it has not lost its relevance.

Local network example

A local network is a group of interconnected devices: PCs, televisions, printers, usually located no further than one room. Devices use shared memory, servers, thus complement each other. Such a connection allows you to create a play area for several PCs, easily and fairly quickly transfer any data, print documents if one common printer is installed, and much more. Combining devices today is more often done using a router, but other connections can also be used, which you can read about below.

Making a connection

It is quite easy to create a connection, and also in different ways: through a router or cable. The device configuration for both methods is quite similar. The difference lies mainly in the connection method: cable or Wi-Fi.

Communication via Wi-Fi, which is used much more often today, can be much more convenient, but connecting two PCs with a cable will cost less if you have not yet installed a router for some reason.

Connection via cable

The oldest form of communication between two machines. All you need to do is connect an RJ45 network cable. The cable must be crossover, although for modern computers regular straight cables can often work. Nevertheless, when buying, it is better to check the type of cable with the seller. When folding the ends of the crossover cable, the colors of the wire ends will differ - this is the main difference. The connection also requires network cards on both devices, but today they are already installed. It is only worth noting that if the network card is already busy with an Internet connection, then it will not work to use it.

Such a connection was just used before in order to play. But it may be convenient for someone today, especially if you still have operating system Windows XP that has a hard time maintaining wireless connections.

After connecting the cable itself, you need to know how to set up a local network between two computers:

  • Control panel, select the item regarding network connections.
  • We select there created by us, right-click on it, select "Properties"
  • Further, depending on "Windows": for Windows XP we select the Internet Protocol (TCP / IP), for Windows 7/8/10 - Internet Protocol version 4.

  • Enter the IP address manually: 192.168.xxx.xxx. The last six digits can be entered independently, as long as they are not repeated for different devices.

  • On Windows 7, you will also need to go to the Network Control Center, there, through the "Settings" item, select "Private" for our network.
  • Then in the Control Center, enable file sharing, network discovery, and disable password protection.

After that, you also need to set up sharing. This is done so that the PCs can exchange any files. The methods differ on different OS. On WindowsXP:

  1. Section Network connections, go to "Service", select "Folder Options".
  2. Tab "View", put a tick opposite "Use simple file sharing".
  3. Next, go to the "System Properties" window: RMB on "My Computer" - select the Computer name.
  4. Click on "Change", select "Member" - the working group. Coming up with a common group name for both PCs.
  5. My computer, right-click on hard drives (for example, Windows (C :)), in the "Access" tab, click on the link, set the share permission.

That's it, access to the files of the selected disks is completely open. With Windows 7/8/10, we proceed as follows:

  • Control Panel, then Folder Options.
  • We put a tick “Use the sharing wizard”.
  • The following steps will be the same as for XP.

Connection via a router

This is the most convenient way, since it allows you to connect not only two, but more computers or other devices that support Wi-Fi. You can play on such a connection without long settings.

With this connection, IP addresses will be set automatically. To use shared files, you only need to share the files, and then add two computers to one workgroup, as described above.

Now, to transfer files, you just need to enter using the address bar the computer name: \\\\ name \\. You can also do this through the Network Connections section. It is also worth securing your personal or especially important files so that no one can access them from a nearby computer. To do this, it is best to indicate disks that do not contain information important to you. For example, a disk that contains data accounts users, it is better not to make it open to everyone, or, using the settings menu for files and folders, restrict access to them: RMB on the desired folder, then select the sharing settings there.

LAN play

So, we managed to connect two devices to the same network without the Internet, let them exchange files. How to start playing on a local network?

For this, as a rule, no additional settings need to be made. We just turn on the game and, if it is possible to play over a local connection, select the appropriate item, and then play on the one we have already created.

For different games the connection to the shared server may vary. Somewhere you will need to enter the IP or PC name. For Minecraft, Counter strikefor example, you will need to create a server. But as a rule, everything is done quite simply.

Hamachi

This happens quite rarely, but sometimes a game does not allow you to play over the Internet, but it does over a local network. Do not despair, even if it turned out that your friend lives far away from you.

Hamachi program allows you to emulate a local connection and thus connect a PC to it via the Internet. To do this, you just need to download the program, register, and then create a new connection, come up with a name for it and, if necessary, a password. Then you can easily use this network to play.

As you can see, connecting computers to a local area network is a fairly easy process. It will not take you much time, and you can connect two PCs, and then play with friends, being both far from them and being in the same room with them.

Ways of creating a connection are suitable for all Windows, starting from XP, ending with "Ten".

Good time spending through games on the computer has become the norm for a large number of people. Remember how, as you played one game after another, you wanted more and more something new? Something truly exciting and emotional. Unfortunately, it so happened that many games that are released at the moment do not have an outstanding storyline, atmosphere and other attributes of a quality product. However, the main thing that computer games will never achieve perfectly is Artificial Intelligence, which ideally copies human behavior with its behavior. I think everyone understands why this task is impracticable - each person is unique, and it is impossible to predict his actions in the game.
But why rack your brains over this problem, if you can just take and invite your friend for an online battle? After all, now, in the age of high technologies, it is easier than ever to do it. Let's take a look at how to play computer games over a local network.


1) The first and easiest way to connect two computers to one local network is to connect them to one Wi-Fi network. As soon as this happens, they will automatically find themselves on the same local network, all you need to do next is to go to the game you want and create a local network connection. So, if you are the proud owner of a Wi-Fi router, or, more simply, a switch with Wi-Fi function, then you can safely play with your friends over a local network without connecting any wires or setting anything up. If technical progress has bypassed you, do not despair - routers are not a luxury item, you can easily buy it in a computer electronics store for 1000 rubles.
2) The second method, in addition to providing the ability to play over a local network, will give you the opportunity to play your favorite game without even forcing a friend to go to your home - the whole game takes place via the Internet. Surely many will say that they have already heard about the game via the Internet, however, it comes about other. Imagine that in any game you need, there is no way to play over the Internet, and only play over a local network is available. Of course, if you live in a neighboring house, then it will not be difficult to take a laptop and go to a friend's house, but what if you have a stationary computer instead of a laptop? Lugging a heavy system unit along with a monitor? I don’t think this is the best option, but even if you are ready to do anything to play with a friend, believe me, if he lives in another country, then even with a laptop for the sake of one game, you will not go to him. What to do? Mission Impossible? Not at all. It is for such cases that a wonderful program called Hamachi was invented. After all, it is one of the few that has the ability to emulate a local network between two computers through their connection via the Internet. Everything is very easy - download the program (use it for non-commercial purposes for free), register in its system, ask your friend to do the same and create your own network. (Click the triangle in the program menu and select the "Create a new network" item) name it whatever you like, set a password if necessary and say the name of the network to the second player. As soon as it enters your Hamachi network, a local network will be emulated between your computers, wherever they are.
3) If you do not spend hunting on a Wi-Fi router, and the Internet is not connected to your computer (are there still such people?), Then you can use the most famous method - connecting via a network cable. It costs much less than a router, however, it will take you a little more time to configure it than in the case of playing through Hamachi.
Now you know, how to play on a local network... So, if you have a network cable and two computers in which there is a network card, then in order for the computers to “see” each other on the local network, you need to go to the “Network and Sharing Center” item, then go in the "Changing adapter settings" section and in the window that appears, open the "Local area connections" properties. In it, select to change the parameters of the TCIP v4 protocol and uncheck the box "Obtain address automatically" to "Use next" and enter 192.168 in the "IP address" field. X.X, where X is any number from zero to 254. Similar actions must be performed on the computer of your friend, but with one difference, the last number X must be unique for each computer, ie. if you have registered 192.168.7.10 on your computer, then the last digit in the address of another computer must be any other than "10".

The ways

There are two methods by which you could play with other people.

  • The local network.
  • The Internet.

In essence, they are very similar and do not differ in many respects, but each has its own nuances that need to be remembered. For example, you can create your map for a long time and persistently, and then make it available for local game... Do not forget to make a copy, otherwise it will be very disappointing when other players destroy what you have painstakingly created.

Anyway, you will need some things, without which you will not be able to play with other people. This is the Internet, a Minecraft client, direct hands. You also need to remember that you will have to make changes to the computer settings, so be careful, all responsibility for bringing the PC to a non-working state will fall on your shoulders. Now let's figure out how to play Minecraft with friends.

The local network

Let's imagine that there are a couple of computers with no Internet access, and they are located in the same room. Moreover, a local network exists and is configured between them. In this case, you can play Minecraft online. 2 friends have to install the same client version on both computers. Now the sequence of actions is quite simple:

  1. One of the players must create single player with the desired settings.
  2. After that, he needs to press ESC and open the game for multiplayer.
  3. A message will appear in the chat about starting the server with a specific IP-address. This is what you need to remember.
  4. The client also starts on the second computer. Only the other player enters the multiplayer mode already. If the game does not automatically find the server, then you need to add it by entering the IP that you remembered a little earlier in the search bar.

Thus, the question of how to play together in "Minecraft" on a local network is solved.

Imaginary network

If your computers are separated by vast distances and connected exclusively by the Internet, you can also play on a pair. There are different ways how to play together in "Minecraft" over the Internet, so first we will consider an option that does not require advanced computer settings.

To do this, you need to download and install a utility like Hamachi. Both friends must install it and register, after which one of them creates a server room in the program, to which his friend must connect. This method creates a virtual private network - analogue of a home local network, only organized via the Internet. The shrewd user has probably already realized that further actions are similar to the previous paragraph. There is only one "but". If your computers cannot see each other, then add Hamachi to the exceptions of the firewall and antivirus.

the Internet

If you do not want to be wise again? Theoretically, if you download the same version of the client from one site and perform all the same manipulations as in the first case, you will be able to connect to a friend. On the other hand, you can use Minecraft. Download it from any site specializing in this game, install and run. After that, you just have to send your address to people with whom you would like to play together. There is nothing difficult about this. So good luck with your cube world exploration and multiplayer attempts. And most importantly, if something does not work out, do not lose heart and try again and again, then you will certainly succeed.

Chess