SuperJumper:A2DOpenGLESGameDevelopmentGuide
立即解锁
发布时间: 2025-08-24 00:52:56 阅读量: 4 订阅数: 16 


Android游戏开发实战指南
# Super Jumper: A 2D OpenGL ES Game Development Guide
## 1. Defining the Game World
### 1.1 Target Resolution
We first need to define a target resolution for graphical assets. A common choice is 320×480 pixels (aspect ratio of 1.5), which is a relatively low practical resolution. However, if targeting tablets, resolutions like 800×1280 or 480×800 (a typical Android handset) can be used. The principles remain the same regardless of the target resolution.
### 1.2 Pixel - Meter Mapping
We establish a correspondence between pixels and meters. For 2D games, a recommended mapping is 32 pixels to 1 meter. By overlaying a 320×380 - pixel mock - up with a grid where each cell is 32×32 pixels, we can map it to 1×1 - meter cells in the game world.
### 1.3 Object Sizes
Based on the grid - overlaid mock - up, we can estimate the width and height of objects in meters. The following table shows the sizes of the bounding rectangles of different objects:
| Object | Size (meters) |
| ---- | ---- |
| Bob | 0.8×0.8 |
| Platform | 2×0.5 |
| Coin | 0.8×0.5 |
| Spring | 0.5×0.5 |
| Squirrel | 1×0.8 |
| Castle | 0.8×0.8 |
These sizes are used for collision detection and can be adjusted according to the game's performance.
### 1.4 View Frustum Size
The view frustum will show 10×15 meters of the game world.
### 1.5 Velocities and Accelerations
The velocities and accelerations in the game depend on the desired game feel and usually require experimentation. Here are the values we determined:
- Gravity acceleration vector: (0, - 13) m/s²
- Bob's initial jump velocity vector: (0, 11) m/s
- Bob's jump velocity when hitting a spring: (0, 16.5) m/s
- Bob's horizontal movement speed: 20 m/s
- Squirrel's movement speed: 3 m/s
Bob's horizontal movement speed varies between 0 and 20 m/s depending on the phone's tilt. We use the accelerometer's x - axis value in portrait mode. When the phone is not tilted, the x - axis reports 0 m/s². When fully tilted left, it reports approximately - 10 m/s², and when fully tilted right, it reports approximately 10 m/s². We normalize the accelerometer reading by dividing it by 10 and then multiply it by Bob's maximum horizontal speed.
```mermaid
graph TD;
A[Phone Tilt] --> B{Accelerometer Reading};
B --> C{Normalize Reading};
C --> D{Multiply by Ma
```
0
0
复制全文
相关推荐








