1.1 Basic knowledge of scheduler in Game Development

Source: Internet
Author: User

Games

1.1Schedule events in the game

One scheduling can effectively help the following game technologies, including physical simulation, character movement, collision detection, AI in the game, and rendering. One of the key issues with all these technologies is time. When hundreds of different objects and processes need to be updated at different times, many of these simulation technologies become very complex.

An important capability of the scheduler is that it can dynamically add and delete objects, which can smoothly add new objects to the game and participate in simulation together with other objects in the game, and then delete it from the scheduling when it is not needed.

1.1.1Composition of Scheduler

The basic components of the scheduler include the task manager, event manager, and clock. With these component schedulers, you can generate time-or frame-based events and then call the corresponding event processor.

The task manager processes task registration and organization. Each task has an interface that contains a callback function that can be called by the manager. The task manager maintains a task list, which contains the scheduling information of each task.---For example, start time, execution frequency, duration, priority, and other attributes. It may also contain user data pointers or performance statistics.

The event manager is the core part of the scheduler. Each task in the task manager defines one or more events to be processed. An event refers to the time required for a task to be executed. The responsibility of the event manager is to generate necessary events to execute corresponding tasks.

Real Time and virtual time: scheduling a real time is very simple in concept.-The time manager keeps repeating and looks at a real time clock. When the target arrives, it triggers an event. The scheduler of a Virtual Event divides the time into frames. Tasks are executed in batches between frames, run in virtual time, and then synchronized with the real time when each frame is rendered.

The clock component is used to track the real time, the current simulation time, and the number of frames. The time manager sorts and generates events. In some cases, multiple tasks may be set to run at the same time. Execute with a higher priority. If the priority is equal or the system has no priority, the task is executed in turn. We often need to dynamically change a registered task attribute, which may involve changing its priority, period, the duration, or you need to delete it before it is found. In order to update the attributes of a task, we must use an external method to locate the task and use a unique registration method.IDTo mark a task.

1.1.2A simple Scheduler

The scheduler is designed mainly on two components. ----- The scheduler engine itself and Itask Plug-in interface. To run the scheduler, you must haveProgram. In a non-graphic program, this requires that it be placed in a loop and then executed in the execution order. While (running) schedframe. executeframe (); There are two ways to integrate the scheduler into a message-driven graphical interface. The first method is to modify the message loop to process messages and call the scheduler. This is the easiest way to think of, but there is a drawback, that is, when the window size is changed, the scheduler will stop working. The second method is to create Windows Clock, which uses the clock message to call the scheduler. Since the clock message is not interrupted by the window drag, the scheduler can continue to run in the background.

Simulation: The scheduler can be used to drive the simulation system. To achieve animation and collision detection, most simulation engines divide time into independent small pieces.

Related Article

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.