Game concept and Three.js plus Cannon.js spec for a cube-maze puzzle platformer where pressing R rotates gravity by 90 degrees.
Game Concept: A puzzle-platformer named "Gravity Shift" where players rotate the entire world to navigate a 3D low-poly labyrinth. The environment is minimalist, using pastel gradients and sharp geometric shapes.
Technical Prompt:
Build a 3D platformer using Three.js and Cannon.js. The world is a cube-shaped maze. When the user presses 'R', rotate the world.gravity vector by 90 degrees.
JavaScript
// Gravity rotation logic
world.gravity.set(0, -9.82, 0); // Default
function rotateGravity() {
let newG = new CANNON.Vec3(-world.gravity.y, world.gravity.x, 0);
world.gravity.copy(newG);
}
Include smooth camera interpolation using Lerp to follow the player's rigid body during shifts.游戏概念:一款名为“Gravity Shift”的解谜平台游戏,玩家可通过旋转整个世界来穿越一个3D低多边形迷宫。环境风格极简,采用柔和的渐变色调和尖锐的几何形状。
技术提示:
使用 Three.js 和 Cannon.js 构建一款3D平台游戏。游戏世界是一个立方体形状的迷宫。当用户按下“R”键时,将 world.gravity 向量旋转90度。
JavaScript
// 重力旋转逻辑
world.gravity.set(0, -9.82, 0); // 默认值
function rotateGravity() {
let newG = new CANNON.Vec3(-world.gravity.y, world.gravity.x, 0);
world.gravity.copy(newG);
}
在重力切换期间,使用 Lerp 实现摄像机平滑插值,以跟随玩家的刚体移动。