- XNA 4 3D Game Development by Example:Beginner's Guide
- Kurt Jaegers
- 485字
- 2021-08-05 18:55:28
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.

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.
- 在你身邊為你設計Ⅲ:騰訊服務設計思維與實戰
- Hands-On Data Structures and Algorithms with Rust
- iOS and OS X Network Programming Cookbook
- 信息學競賽寶典:數據結構基礎
- 科研統計思維與方法:SPSS實戰
- 中文版Access 2007實例與操作
- Web Services Testing with soapUI
- 算法設計與分析
- 中國云存儲發展報告
- Hands-On Deep Learning for Games
- AndEngine for Android Game Development Cookbook
- 大數據技術體系詳解:原理、架構與實踐
- 基于數據發布的隱私保護模型研究
- ECharts數據可視化:入門、實戰與進階
- Artificial Intelligence for Big Data