Start my first game engine production

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq493453700/article/details/72833924

Engine developed from scratch. Of course not very high. Getting students can look you want.

First of all I choose the platform PC platform. Language selection junior high school a few blind chaos to learn c ++. I want to be a 2d game. Internet to find several libraries began to do. After the course, she ran into a bottleneck. So in order not to make detours. Outset we learn a lot of basic knowledge. So first:

The basic principle is what the game?

My own understanding is, of course, in terms of simple, clear screen → through the elements of the queue (update data) → Rendering (picture traverse the queue to start from scratch), such a process, the cycle 60 times per second. That is 60fps game. This is a simple game.

An analogy. Demonstrates what is the pseudo-code:

vector<object*> objects;//弄一个vector数组

objects.push_back(new object);//添加元素
objects.push_back(new object);
objects.push_back(new object);

while(1)
{
	clear();//清空画面
	for(unsigned int i = 0; i < objects.size(); i++)
	{
		objects[i]->render();//更新数据并绘图
	}
}

Of course, the update data can separately calculate and plot, the better.
 

 

What a simple engine needs?

 

  1. Create a window
  2. Basic drawing functions
  3. Refresh and pictures queue
  4. Mouse and keyboard interaction engine
  5. Text display
  6. Sound Playback

 

I can see a simple engine that does not include the object and object data updates. Because the basic functions of a simple engine that can display pictures. As for this image size, location, etc., it is provided by the object. So as to show a vivid picture of the game.

For example, an apple, his place in the (0,0), then update the data every time, Apple will be a map attached to this position. When apples fall down, for example, it fell to (0, -1), which is updated location, location maps that have changed, and so on. We can see the process of an apple falling down. In other words, the game world and the world points table in the world. In the world composed entirely of data. And so that we can see the world, you need to picture composition table in the world. Of course there is no picture, this world also exist, this is Apple still fall down. But we do not see it. Of course, this would wander back knowledge of the physics engine, it will not speak here.

I wrote it myself engine encountered bottlenecks later, went to the tutorial. But the online tutorial is very fragmented, full of little, even if there is a fee.

Later, I found this (over the wall needed): Sparky Engine (How the To the Make A Game Engine) Series

And I like to use c ++ and opengl development. The future will be updated from time to time.

Finish.

local

挖槽,看了几百年前自己写的这个文章,也太蠢了8,很明显坑了,不过留下了些代码
在这里:https://github.com/r5r6ty/type1engine

 

Guess you like

Origin blog.csdn.net/qq493453700/article/details/72833924