2D online game development (network) (2)

xiaoxiao2021-04-05  252

2D online game development (network) (2)

Author: akinggw

In the previous chapter, I simply explain what is Raknet, which is beneficial. In this chapter, we will explain how to configure Raknet in IDE and test a program.

Since the author of Raknet uses VC . Net, on the author's home page, he explained how to configure Raknet in VC . Net, if you use VC . Net, you can see the above article.

And I am using DC , so I will explain how to configure Raknet in DC . If you are using VC6, I suggest you upgrade immediately to .NET. Because it is very troublesome in VC6, many of the functions in the Raknet, it doesn't, it needs to be reinstalled, including STL.

After extracting RakNet.zip, you can't use it directly because it doesn't have a lib file, which requires you to recompile. Under the Raknet file, there are multiple project files, with VC and DC. What we need is DC. If you install DC first, you can see the DC project file icon.

Open it, then press "F9" to compile files. If you are successful, you will find the file with Raknet.a in the Raknet file, which is the library file used by DC .

In the VC, the library file extension is the end of the LIB, while in the end of the DC.

Copy your Raknet.a to your DC file in the lib directory, address reference: C: DEV-CPPLIB.

Then copy all the files in the include directory in the decompressed Raknet file to the Include directory in the DC file, address reference: C: dev-cppinclude.

So far, our file copy is completed, then open DC, create a new project.

Then create an empty project:

Select "Project Option" in "Project".

Add the following statement in the "Linker" option in the "Parameters" table:

LIB / RAKNET.A

LIB / libws2_32.a

Then select OK.

The project configuration is complete.

Then create a source code file and rename main.cpp.

Open an example of a RakNet, the path reference is:

E: RaknetSamplescode SamplesChat Example

Open a C file, such as Chat Example Server.cpp.

Copy all the contents of Chat Example Server.cpp to the main.cpp file.

This is a server file, press ""

F9

"After compiling, the results are as follows:

If your program execution results are as follows, you have already configured; if not, you may have an error in some place, please check it carefully.

In the next section, we will explain the functions in the Raknet.

转载请注明原文地址:https://www.9cbs.com/read-132147.html

New Post(0)