点餐页做好了,小禾想加一个接饭团游戏。重力、碰撞、声音,都得从头写吗?The snack shop needs a catch-the-rice-ball game. Must He write gravity, collisions and sound from scratch?
第 1 步:借一间工具齐全的工坊Step 1: Borrow a workshop
饭团要落进篮子,需要哪些工具?What makes the rice ball fall into a basket?
游戏引擎是一套可复用的工具。它能画图、播放声音,也能模拟碰撞。小禾把饭团和篮子放进场景。场景就是物体组成的舞台。他再写规则:接住加一分。工具处理共同问题,规则决定怎么玩。引擎不会自动把点子变成好游戏。A game engine is a reusable toolkit for graphics, sound and other common tasks. He puts the rice ball and basket into a scene: a stage made of objects. Then he adds a rule: catching a ball earns a point. The toolkit handles shared machinery; his rules define the game. An engine does not automatically make a game enjoyable.
第 2 步:一帧接着一帧Step 2: One frame after another
舞台不会自己动,接下来怎么办?A stage does not move itself. What happens next?
引擎反复读操作、更新状态、画出画面。向右按一下,篮子的位置就改变。饭团的位置也按物理规则更新。连续画面让我们看到运动。图中的每秒六十次是示例,实际帧率会变。物理更新也可用固定时间步。时间处理不当,快电脑上的饭团会落得更快。The loop reads input, updates state and draws a frame. A right press moves the basket; physics updates the ball. Successive images appear to move. Sixty updates per second is an example, not a universal engine rule. Physics may use a fixed time step separate from rendering. Poor time handling can make a ball fall faster on a faster computer.
第 3 步:同一规则,不同设备Step 3: Same rules, different devices
游戏做好后,手机就能直接玩吗?Can the finished game immediately run on a phone?
引擎常能导出多种平台版本。但屏幕、性能和操作方式不同。键盘操作需要换成触屏按钮。小禾还要测试手机是否流畅。下面开关模拟重力、碰撞和摩擦。碰撞关闭时,画着地板也拦不住饭团。看得见的画面,不等于参与计算的碰撞体。Engines often support several export platforms, but screen sizes, controls and performance differ. Keyboard controls may need touch buttons. He must still test the phone build. In the experiment, gravity, collision and friction are separate switches. A drawn floor cannot stop the ball when collision is disabled: visible artwork and collision geometry are different things.
🎮 饭团物理工坊🎮 Rice-ball physics workshop
开关重力、碰撞和摩擦,调弹性,再运行四项任务。Toggle gravity, collision and friction, adjust bounce, then run four challenges.
一句话记住它:Remember: 引擎提供通用工具,你用物体和规则组织游戏。An engine supplies reusable tools; objects and rules turn them into a game.
场景组织物体与行为。Scenes organize objects and behavior.更新状态与绘制画面各有职责。State updates and drawing have different jobs.换平台后仍需测试控制与性能。A new platform still needs control and performance tests.