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

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.

主站蜘蛛池模板: 阳山县| 洛宁县| 新余市| 左权县| 太仓市| 泰安市| 鹿邑县| 芜湖市| 富裕县| 桦甸市| 五家渠市| 牙克石市| 乌兰县| 灵武市| 方城县| 宁海县| 朝阳县| 岑巩县| 阿荣旗| 盈江县| 社旗县| 呼和浩特市| 杭锦旗| 兴仁县| 普宁市| 深水埗区| 家居| 珠海市| 西宁市| 兴山县| 称多县| 丽水市| 盐源县| 武胜县| 绥滨县| 宾阳县| 蓝田县| 宽城| 克什克腾旗| 云安县| 靖西县|