官术网_书友最值得收藏!

Designing the game

Cube Chaser will take place in a randomly generated 3D maze. We will use triangle lists to build the floor and walls of the maze and instruct the graphics card to draw them to the screen.

The maze itself is actually a 2D construction, with the walls being rendered in 3D. The floor of the maze will be laid out along the X-Z plane, with the walls extending upwards along the positive Y axis. The player will be able to move in the X and Z plane, but will be restricted to a single, pre-defined elevation along the Y axis.

3D coordinates

You may have noticed in the previous statement that the player will move along the X-Z plane. If you have spent any time developing 2D games, you will likely be used to working with X-Y coordinates, with X running across the screen from left to right and Y running down the screen from top to bottom.

When we move into 3D, we no longer have a fixed viewing angle on our action. In a 2D game, we typically describe actions in the X-Y plane for a side-scrolling game, overhead shooter, or a puzzle game. Since there are only two dimensions to deal with, the relationship between objects on the screen is the same type of relationship they would have if you drew them on a piece of paper. The only time we even really consider a third dimension in a 2D game, we refer to it as the Z-Order, or the order in which the sprites will be drawn to make some appear on top of others.

3D coordinates

Knowing that we have three axes to deal with, X, Y, and Z, the next step is to determine how coordinates along each axis relate to the others. XNA uses a right-handed coordinate system, meaning that you can try to contort your hand in various directions to have your palm, fingers, and thumb pointing along the positive directions for each axis. Without spraining anything, what it really means is that if you were standing in the 3D world at a point where you could see the positive Y axis shooting up into the sky and the positive X axis running off to the right as in the previous diagram, the positive Z axis would be pointing towards you.

Tip

Left-handed and right-handed coordinates

XNA uses a right-handed coordinate system. If you hold your hands with your palms facing up, and curl your fingers 90 degrees up from your palm, your palm points along the positive X axis, and your fingers point along the positive Y axis. If you point your thumb out away from your hand, the thumb points along the positive Z axis, relative to X and Y. Which hand you use determines which direction is positive along the Z axis. The coordinate system in XNA is based on the right-handed rule.

主站蜘蛛池模板: 邯郸县| 镇宁| 衡南县| 岐山县| 大宁县| 邯郸市| 芦山县| 丰镇市| 乳山市| 克山县| 息烽县| 红桥区| 舒城县| 通化市| 木里| 越西县| 蚌埠市| 保德县| 霍邱县| 瑞昌市| 卢龙县| 开封市| 海城市| 宣汉县| 黎城县| 沛县| 克东县| 宾阳县| 乃东县| 崇左市| 肥西县| 宜宾市| 许昌市| 香河县| 碌曲县| 丹江口市| 广昌县| 罗平县| 辽阳市| 筠连县| 合作市|