PHP Web Game Learning Xnova (Ogame) source Interpretation (v) _php Tutorial

Source: Internet
Author: User
VI. Main game Interface (frames.php)

frames.php file function is to display the main game screen, first look at the following code:

$InLogin = false; $XNova _host  = $_server[' http_host '); $XNova _script = $_server[' Script_name ']; $Uri _array   = Explode ('/', $XNova _script);//On Vire le Scriptarray_pop ($Uri _array); $XNova _uri   

The above code is mainly to spell out the URL of the server, relatively simple, the preceding variable $inlogin temporarily do not speak, and so we specialize in explaining common.php when, focus on.

We then include two files that we talked about earlier, and finally output a large piece of HTML code. It is important to note that the HTML code constructs two frames, respectively leftmenu.php and overview.php, which I will analyze below.

Seven, left navigation bar (leftmenu.php)

This file is actually very simple, except for our common code, just declare the Showleftmenu () function, and finally output the page with display (). function Showleftmenu () is not difficult, the code is nothing more than a gettemplate template file, get the parameters of the server settings and the user level of login, and then construct the page. It is important to note that the user level variable $level, when the value of $level is greater than 0, the administrator link is displayed. The value of the $level represents the level defined in the System.mo file, 0 is the average player, 1 is the game operator, 2 is the game manager, and 3 is the administrator.

Viii. Overview (overview.php)

This file is actually the corresponding link in the left navigation bar ' profile ', the main function is to display the current planet's approximate information and user information, including the current state of other planets and so on. The code is very large, in fact the organization is very clear, we slowly look, the previous lines of code we skipped.

This code function is to get the moon on the current planet and check the space used to fix the moon. The Checkplanetusedfields function not only works on the moon, it can also be used to check the planet, without first looking at the code, we continue.

Next is a security verification, you need to set in the parameters to enable this function, you can see for yourself, such code, there are many, I generally do not analyze, the game process is not very related. Next is a switch, two branches, one to rename the planet (give up the planet), temporarily do not look; the other default branch is the process to be performed after logging in, as follows

1. Check the user's message and display the message link if there is a new message
2. The process of expert system, I have removed this logic myself, so I do not intend to analyze
3. Check whether the user has fleet activity, if any, construct Fleet activity Information table, construct using Buildfleeteventtable function, introduce later
4. If the user has other planets, construct a list of other planets and show the current activity of each planet
5. Information on interstellar missile activity that displays its own launch and attacks from other players
6. Other information displays, such as announcements, Google ads, etc.
7. If there is a moon, display the lunar information
8. Here are some of the planet's names, planet Space, user rankings and other information, more clutter

The code of the above process, there are comments, it is not difficult to understand, the following code we want to introduce.

if ($planetrow [' b_building ']! = 0) {updateplanetbatimentqueuelist ($planetrow, $user); if ($planetrow [' b_building ']! = 0 {$BuildQueue = explode (";", $planetrow [' b_building_id ']), $CurrBuild = Explode (",", $BuildQueue [0]); $RestTime = $pla netrow[' b_building ']-time (); $PlanetID = $planetrow [' id ']; $Build = Insertbuildlistscript ("Overview"); $Build. = $lang [' Tech '] [$CurrBuild [0]]. ' (' . ($CurrBuild [1]). ')'; $Build. = "". Pretty_time ($RestTime). ""; $Build. = "\ n";  

$planetrow holds information about the current planet, the b_building of which is the construction queue. The above code first determines whether there is a construction queue, and then according to the current time, update the building information, if there is still a building is not completed, it shows the construction units and construction of the remaining time. About the building queue function, to be introduced in detail later, now skip the first.

Let's briefly introduce one of the previous branches, with three more processes in the branch:

1. Rename the planet, the code is not difficult, and not much to say
2. Abandon the Colonial Planet and display the page where the user wants to enter a password
3. User input password, if the password is correct, update the information of the planet and the user's default planet ID (the moon is not judged)

At this point, the user login to the main interface of the game process is clear, finally entered the game.

http://www.bkjia.com/PHPjc/825513.html www.bkjia.com true http://www.bkjia.com/PHPjc/825513.html techarticle Six, the game Main interface (frames.php) frames.php file function is to display the main game screen, first look at the following code: $InLogin = false; $XNova _host = $_server[' http_host '); $XNova _scri ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.