Tile based ENGINE design - occlusion processing

xiaoxiao2021-03-06  44

The so-called ISOMETRIC should refer to the equidist angle, and perspective, refer to objects in the field, regardless of the same size, and Tile refers to the bricks, the many 2D games we are often seen are TILE For example, the new decisive North Korea, there is a last year's dynasty hegemony ;-), these two games are typical Tile games, the elements in the game are split into a bricks assembled. Different, the former is Rectangular Tile, while the latter is ISOMETRIC. Its Tile has a height, the bottom is a rhombus. Isometric looks closer to the real object, I personally prefer this graphic expression. Since ISOMETRIC TILE coverage, so there is Blocking problems, (Traditional rectangular Tile is no obstruction, but its extension also needs to handle this, but it is simpler than isometric), this may be a difficult point in ISOMETRIC TILE engine design, this paper is to introduce the processing of cloud wind Method. Let's take a look at the map under Isometric. This is a rhombus. Every rhombus is a Tile's bottom. I have compiled each TILE. It is based on the coordinate of the game world, organizes data. You can save a 2D array description map in this form. In fact, you can also compare coordinates in the horizontal direction of the screen, pay attention to the odd row and even lines of the screen coordinates of the odd row and even TILE can be, This is also very convenient. In fact, two coordinates can be converted with a very simple formula. This article does not use this coordinate, which is not mentioned here. If you don't want to blocked problems, the simplest processing method is every time When generating a similar image, press from top to bottom, from the upper right to the left (that is, from left to right, from the left to the right, from the previous), each TILE draws over again. But this is Isometric is a lot of waste, because every tile in Isometric is equal, covering the relationship. Generally, we set the TILE's height unit to the high rectangle of Tile, easy to handle (as shown below). When it is a single layer, such a minimum unit of Tile may be blocked by Tile than its (x, y) coordinate big 1 Tile. Similarly, if a wizel occupies 4 Tiles, it may block its Tile 5. If the object has two layers, Tile that can block this 2x2 object is 10, so on, now you can see an example, in the figure, there are two (fixed) objects, the tree is 2x2, It occupies (2, 2) (2, 3) (3, 2) (3, 3) four tiles, stone blocks are 1x1, occupying (1, 3) this Tile. Elephant (elf) is also 2X2 It is currently in (0, 1) (0, 2) (1, 1) (1, 2) these four TILE. Take a look at another picture: Cain more. Generally, draw isometric The scene is 2 steps, first generate a fixed scene, then draw the elves. Since it is moving, it usually wants to redraw a time per frame (of course, you can also use all heavy pictures, so that each elf is different, Animation is interlaced, raising speed, this technology is more complicated, in my performance is good :-) This example is what the elephant in the figure draws: elephant occupied (0, 1 (0, 2) (1, 1) (1, 2) 4 Tiles, 5 TILEs in the single layer map can be (2, 1) (2, 2) (2, 3) (0) , 3) (1, 3), these five coordinates are easy, the simplest method is to add 1 coordinates of the four TILE occupied by the elephant, (from (x, y) launched (x 1, Y) (x 1, y 1)), repeat the 12 sets of coordinates in the launched 12 groups. Of course, this is not the best algorithm, which is just an example. From the map There is a object on (2, 2) (2, 3) (1, 3), wherein (2, 2) (2, 3) is two parts of the same tree, so only one. (1,3 ) Is a stone. Next, we set a tailoring rectangle to draw an elephant area, and draw it to the tree and stone. Note that the setting of the rectangle here is not less, otherwise this The problem of occlusion is over, which will lead to new occlusion issues;

转载请注明原文地址:https://www.9cbs.com/read-51576.html

New Post(0)