Game engine learning notes: introduction, architecture, design and implementation

Game engine learning notes: introduction, architecture, design and implementation

[[120519]]

Although I have played many games since I was a child, I have only written two games since I started programming. One was a snake game written on the MTK platform in 2011, and the other was a maze game written on an embedded development board in 2010. The first one had about 3,000 lines of code, and the second one had about 2,000 lines.

Both games are very simple, and there are many ready-made examples on the Internet for reference, so the difficulty is relatively low.

In the past two days, I finished reading the game engine chapter of "Android Application Development Revealed" , which I had been putting off for a long time. I gained a lot from it, so I'm writing a reading note here.

Regarding Game Engine, I can think of a few questions:

  1. What is a game engine?
  2. What problem does Game Engine solve?
  3. What is the architecture of Game Engine?
  4. How to design a game engine?
  5. What modules does the game engine include?

Let’s discuss a few issues below:

1. What is Game Engine?

The gaming industry is a huge industry in the world, and a game masterpiece contains a lot of elements. Games involve plots, characters, tasks, levels, maps, image quality, art, music, networks and many other elements. Developing a game actually requires a lot of resources. It is said that North Star's "GTA V" cost hundreds of millions of dollars. Because of this, it is very important to reuse the successful things of previous projects as much as possible during the development process.

In a game, the Game Engine directly controls the plot, levels, art, music, operations, etc., bundling all elements of the game together.

Generally speaking, a Game Engine needs to include the following modules:

  1. Basic framework (rendering, logic, physics, etc.)
  2. Resource Management
  3. Rendering
  4. Basic logic (online games also need to solve the problem of logic synchronization)
  5. Physical (sometimes combined with logical)

—————-Dividing line, the following is an important but relatively independent part——————–

 6. UI 7. 音乐音效8. 网络9. 脚本(有些类型的游戏引擎需要脚本和逻辑的关联性非常强,有些脚本则比较独立)

2. What problem does Game Engine solve?

Game Engine actually effectively reduces the redundant labor of developers when writing programs, while enhancing the portability of games .

Engine is the framework of the game. We need to fill the framework with content to form a game.

An engine is a series of tools and production chains. Mature engines like Unreal 3 and Unity are very convenient to use because their level/scene editors are very user-friendly and support multiple scripting languages. If such engines are used properly, in theory, most of the work of level debugging and object assembly lines can be completely removed from programmers.

3. Game Engine Architecture

游戏= 引擎(程序) + 资源(图像、声音、动画等)

The current Game Engine architecture is a Model-View-Controller architecture, where logic and display are separated, and a logical control flow is used to coordinate client requests and server actions.

  1. View: responsible for interface receipt
  2. Controller: handles the creation and planting of workflows, user input, and the handling of various events
  3. Model: Model, logic, and program function implementation

Message loop->update data->draw each node This is the basic structure of drawing and there will be no major changes.

A large part of the variants of various engines are encapsulation of game logic. Whether it is scripting or direct coding. For example, the older separation of data and functions, represented by C language. The popular class structure, represented by C++. And now Halo Sun's CBSE, component-based architecture

4. How to design a game engine?

<1>. Structural design and functional design

The design of Game Engine includes structural design, functional design and precautions.

Game Engine includes graphics engine , script engine, physics engine, tool module, sound engine, network components, event components, etc.

Android games mainly include an Activity class, a process control class, a game thread class, and a game object class. The Activity class is the execution unit of the game and is responsible for controlling the game life cycle.

Process control: Provides methods for switching between multiple interfaces in the game;

Game thread: constantly monitors various events that may occur, calculates the game status, and refreshes the screen.

<2>. Notes:

The main problem with mobile games is hardware limitations and battery bottlenecks. Insufficient CPU and memory, screen size, sound effects and other limitations need to be taken into account when designing.

5. Implement a game engine

A game engine is just a cooking wok, but having a good cooking wok does not necessarily guarantee good dishes .

The implementation of the game engine is very complicated. It needs to be coded according to the architecture and functional design in the previous section. At present, most of them are object-oriented programming, and various classes are designed. For example, characters, NPCs, props, animations, animals and plants, etc. Students who have spare time can study it.

Some of the popular games recently don’t actually require a particularly awesome game engine. Only by fully exploring the user’s pain points can a good game be designed.

There are many open source game engines available for research, such as Unity3D, Box2D, etc. You can search and research them online.

6. Outlook for mobile games

I have played a lot of mobile games in the past two years. Let me talk about the characteristics of a good mobile game:

  1. Easy to get started, difficult to master , so play and cherish. Mobile games are for the general public, so games that are difficult to get started will be passed. The game must be simple so that players can play it as soon as it is installed;
  2. Interruptible, short-term . Generally, people play games in fragmented time such as on buses or subways, so it provides short-term entertainment effects and allows smooth switching between game and work modes;
  3. Must add SNS elements : A good mobile game should have social elements. You can add LBS to find players around you, play games and interact with friends, or make new friends. Because mobile games are simple, you need to retain players, and adding SNS can retain players;
  4. Make full use of the advantages of mobile phones: The advantages of mobile phones are portability, privacy, and even arrival. Mobile phones are an extension of our bodies, so a good game should make full use of some of the mobile phone's sensors, cameras, networks, and Bluetooth to find out the characteristics in order to design an excellent game.

<<:  Chrome and Android apps are interoperable, so why doesn’t Google have any appeal?

>>:  Understand the functional features and application scenarios of WeChat Enterprise Account

Recommend

Daily Youxian event traffic generation tips!

In the past, when we went to the supermarket to b...

Xiaona is gone, Microsoft Xiaobing is back, are voice assistants really useful?

After Windows 10 2004 separated Cortana and the s...

Salt, the first mineral discovered and eaten by humans

Salt is a necessity for human survival. Throughou...

Lao Liang's Value Investment Stock Selection Course

Introduction to Lao Liang's Value Investment ...

What should I do if I experience roller coaster-like dizziness?

Author: Xiao Lin China Rehabilitation Research Ce...

3 ways to promote user activity in e-commerce apps

As an e-commerce operator , you often have to men...

Douban’s methods and strategies for obtaining traffic!

Not long ago, Pinduoduo's market value surpas...

Exploring Eternity: Gödel and Einstein

Einstein has many intriguing quotes, such as he s...