Mmorgp large-scale game design and development (client architecture part9 of vegine)

Source: Internet
Author: User

Time is a very important thing in people's lives. If we break down the time, we don't know what it will look like. There is also a time module in the client, because different times may handle different things, especially when pursuing high liberalization, time has become a very important core. If there is no time, the game world will lose its balance. games without time will be boring and monotonous. Well, I don't need to emphasize the importance of time any more. You must have understood it. For example, is there time for hours and weather changes in the game? The answer is yes. In this design, what methods does the time interface provide?

Code

Module time file system. h

/*** Pap engine (--) * $ ID system. H * @ link -- For the canonical source repository * @ copyright (c) 2013-2014 viticm ([email protected]) * @ license * @ user viticm <[email protected]/[email protected]> * @ date 2014-3-19 09:35:51 * @ uses vengine time system module */# ifndef vengine_time_system_h _ # define vengine_time_system_h _ # include <time. h> # include "vengine/config. H "# include" vengine/kernel/node. H "namespace vengine_time {class vengine_api system: Public vengine_kernel: node {vengine_kernel_declare_dynamic (vengine_time_system); Public: Virtual void Init (void *); Virtual void tick (); public: // obtain the average time spent by each worker for the last 20 ms float get_looptime () const; // obtain the time consumed by the last frame float get_lastframe_time () const; // obtain the runtime float get_runtime () const Based on looptime _; uint32_t get_nowtime () const; // obtain the frame rate (FPS) float getfps () const; // calculate the time difference, considering the time threshold (49.71 days) uint32_t get_difftime (uint32_t starttime, uint32_t endtime); // obtain the number of frames; // set the server time void set_servertime (time_t _ time ); time_t get_servertime (); protected: Float looptime _; float lastframe_time _; float runtime _; uint32_t nowtime _; float FPS _; time_t servertime _; time_t localtime _; uint32_t tickcount _ ;};}; // namespace vengine_time # endif // vengine_time_system_h _
Explanation

What is frame rate?

Frame Rate is crucial in the client because it affects the running speed of the client, that is, the performance of the client.

The number of frames per second (FPS) or frame rate indicates the number of times the graphic processor can update each second when processing the field. A higher frame rate allows you to get smoother and more realistic animations. In general, 30fps is acceptable, but improving the performance to 60fps can significantly improve the interaction and authenticity, but generally it is not easy to notice that there is a significant increase in smoothness when it exceeds 75fps. If the frame rate exceeds the screen refresh rate, only the graphic processing capability is wasted, because the monitor cannot be updated at such a fast speed, so that the frame rate exceeding the refresh rate is wasted.

Simple

Various activities in Swordsman ol

Summary

The methods provided in the time module show that there are tick (processing per frame), get the program running time, current client time, and server time, these various times will affect some special logic processing of the client. I will not describe them here. The next section describes the UI module.

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.