Ten years ago, the Internet cafes at that time were not called Internet cafes. At that time, there was no king glory and no League of Legends. At that time, Fantasy Westward Journey just launched the Treasure Pavilion system. At that time, the Lich King’s soul was still closed in the Frozen Throne.

Seeking immortals, crossing the fire line, journey, Tianlong Babu... At the same time, the number of online games with millions of people has emerged. In the era of Chinese online games, the underground city and the Warriors are undoubtedly the most dazzling ones.

How hot was DNF in the past? That year Xiaobian was still in junior high school, and went to Internet cafes with classmates. All the rows were playing DNF. At that time, someone broke a pair of dragons and shadows, and the entire Internet cafe was blown up. The silly son of a landlord immediately put the mobile phone. There, then rushed home and took 800 pieces. When I went out, I fell. I climbed up and continued to run. While running, I yell, don’t sell it to others...

However, playing games is not as good as playing games . The game number is a bunch of code in the eyes of programmers. So today, Xiaobian wants to tell you how to develop games.

As a horizontal screen fighting game, beautiful pictures and smooth movements are the essence of DNF, then we start with pictures and actions.

Initial knowledge about GDI

What is GDI? GDI is the abbreviation of Windows' native graphics device interface (GraphicsDeviceInterface). The main task is to exchange information between the system and the drawing program, and to process the graphics and image output of all Windows programs.

With it we can easily draw graphics on the screen. It can also be used to develop games that are not very demanding, such as Contra playing as a child, Super Mario and other small games, or some RPG (role-playing) games, which we can all use GDI.

Although LOL, DNF, QQ Hyun Dance and other games are graphical interfaces such as DirectX or OpenGL, the simplest for novice white is GDI.

Prepare a background image in BMP format, create a form, draw on the form, and then get the device environment DC of the form through the GetDC function.

After obtaining the device environment, you also need to create a device environment in memory. We draw the picture in memory and draw it directly to the device environment of the form.

About the initial animation implementation

3D is the art of rendering. The scheme with animated state machine and mixed tree is basically standard today, such as the common Unity Mecanim, UE4's Animation Blueprint.

So how do you use GDI to animate in the game?

2D games are the art of textures. There are basically two ways to map. One is to use a timer, and the other is to use a message loop. Currently, the second drawing method (message loop) is used, which means that the animation in the game. They are all posted one frame at a time, just like a movie.

For example, this animation (the material comes from DNF), save them through an array, and play them in turn. Here is the partial code:

Running effect chart:

Does it feel good? In fact, games like Dungeon and Warriors are more suitable for novice whites. Compared to the skeletal animation of 3D games, the sequence of 2D horizontal games is simpler.

In this era of entertainment, the game has been integrated into our life has become a way of life, game development is also an extremely popular industry in the present and the future, but for beginners, lack of experience and guidance will often be difficult.


CBD vape pen

Suizhou simi intelligent technology development co., LTD , https://www.msmsmart.com