返回资讯中心
外部精选
软件工程
#开发者实时流

Castle Quake 2: A modern port of Quake 2 using the Castle Game Engine

A port of Quake 2 to the Castle Game Engine (Object Pascal / Free Pascal), the sibling of mariuz/castle-quake1. Bundled with the original Quake 2 shareware demo data (demo1–demo3, the first three Outer Base levels), and…

Hacker News 最新mariuz2026/10/27 · 昨天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

A port of Quake 2 to the Castle Game Engine (Object Pascal / Free Pascal), the sibling of mariuz/castle-quake1. Bundled with the original Quake 2 shareware demo data (demo1–demo3, the first three Outer Base levels), and able to load a full Quake 2 install (baseq2/pak*.pak).

Quake 2 BSP (IBSP v38) world geometry

All 19 lumps parsed; faces batched per texture + surface flags into X3D TIndexedTriangleSetNodes loaded into TCastleScene with PreciseCollisions for walking and ray casts.

WAL wall textures decoded with the pics/colormap.pcx palette and served through the quaketex: URL protocol.

Baked RGB lightmaps packed into one atlas per model and applied with TMultiTextureNode (MODULATE × 2, the overbright factor in the unlit material's emissive colour, which also works in WebGL), like Quake 2's GL renderer.

Surface flags: SURF_SKY (invisible but solid), SURF_NODRAW, SURF_WARP (animated with a GLSL PLUG_texture_coord_shift shader effect, non-solid), SURF_TRANS33/66 (blended), SURF_FLOWING (scrolling TTextureTransformNode).

Animated textures following the WAL animname chains at 2 frames/second.

Light styles: flickering, pulsing and switchable lights. Faces lit by animated styles live in a separate lightmap atlas that is recomposed from their up to 4 style layers (10 Hz, only when a style changes) and re-uploaded; light entities with a targetname switch on/off, target_lightramp fades them.

Skybox from env/<sky>{rt,lf,up,dn,bk,ft}.tga|pcx via TCastleBackground (TQuakeMap.Background, also shown in the CGE editor).

SP2 sprites (IDS2 v2): the BFG10K ball and its explosion, as animated camera-facing quads.

MD2 models (IDP2 v8): monsters, items, weapons, projectiles and the first-person view weapon, with interpolated frame animation, PCX skins (index 255 transparent) and per-model tint sampled from the lightmaps below them (Quake 2's R_LightPoint, done by walking the BSP nodes). Shells like RF_SHELL_*: a translucent copy pushed 4 units out along the normals, blue on the view weapon with quad damage, red with invulnerability, green on monsters whose power armor absorbs a hit (the brain's power screen).

Brush entities as TCastleTransforms: func_door, func_door_rotating, func_plat, func_button, func_rotating, func_train (follows path_corners), func_wall, func_explosive (shootable, chain reactions).

Quake 2 entity logic: target / targetname chains (G_UseTargets), trigger_multiple/once/relay/counter/key/hurt/always, delay, target_changelevel (with map$spawnpoint; levels of a unit remember their state when you come back), target_crosslevel_trigger / _target, target_secret/goal/help/speaker/explosion, misc_teleporter, messages and the help-computer objectives.

Dynamic lights: muzzle flashes, explosions, rockets, blaster bolts and BFG balls light the walls and models around them (a shader effect on the lightmaps).

All 10 weapons plus hand grenades: Blaster, Shotgun, Super Shotgun, Machinegun, Chaingun (spins up from 1 to 3 bullets per frame), Grenade Launcher (bouncing grenades), Rocket Launcher (splash damage), HyperBlaster, Railgun (piercing, spiral trail), BFG10K, hand grenades (hold fire to cook, throw harder the longer you hold, explode in your hand after 3 s). Guns run on Quake 2's weapon frames: shots leave on the frames the original fires them, refire when the animation allows, and switching weapons plays the put-away and raise animations (the BFG fires its ball 0.8 s after the flash, like the original). Shots are Quake 2 traces through the map's brushes, doors and plats, monster boxes (shorter while a monster ducks), corpses and barrels; grenades bounce off the surface they hit.

Items: health, armor (jacket/combat/body with Quake 2 protection and salvage rules, shards), ammo, quad damage, invulnerability, adrenaline, bandolier, ammo pack, keys (data CD, power cube, pyramid, spinner, pass, blue/red key, commander's head, airstrike marker).

Monsters (19 types defined; the demo has soldiers, enforcers, gunners, berserkers, flyers, parasites and tanks): sight via line-of-sight checks, chase at their Quake 2 pace (walk / run frames moving the original per-frame distances), floor following, melee / hitscan / blaster / rocket / grenade / railgun attacks, pain and death animations, gibbing into flying gib models; monsters detour around obstacles and won't walk off ledges; idle monsters walk their path_corner patrols (with wait and pathtarget), alerted ones first run to their point_combat (and hold it when flagged); monster projectiles can hurt other monsters.

View weapon in its own transparent viewport (WeaponViewport, cleared depth), so it never clips into walls.

Invisible player-clip walls rebuilt from the clip brushes' planes.

Player physics ported from Quake 2's pmove (TQuakePlayerMovement, a behavior on the camera): Quake 2's 32 × 32 × 56 player box (32 high when crouched) swept through the map's BSP brushes like Quake 2's collision model (QuakeTrace: exact sliding along walls, slopes and creases, 18-unit step-ups with a smoothed view, platforms and doors carry and push you, monsters block you), friction 6, accelerate 10, air control 1, gravity 800, jump 270, 18-unit steps, crouch (eye 46 → 22, speed 100), ladders (forward + look up / down, jump / crouch), falling damage and jump pads (trigger_push). Tunables are published, so they can be tweaked in the editor; Active = false falls back to TCastleWalkNavigation movement. Swimming (PM_WaterMove: water level from BSP leaf contents, water friction, sinking, swim up / along the view), underwater tints, lava / slime damage, drowning after 12 seconds, splash sounds; warped liquid surfaces don't collide. Plus noclip, damage with armor absorption, death and level restart.

HUD drawn with the original pics/*.pcx big numbers, ammo/health/armor/weapon/key icons and crosshair (TDrawableImage), pickup notices and damage / quad / invulnerability screen blends.

Spatial audio from the PAK's WAVs via TCastleSoundSource (doors and lifts loop their move sound, idle monsters mutter), with Quake 2's distance attenuation mapped to OpenAL's linear model; ambient target_speaker loops (80–90 per demo map) and triggered sounds; optional CD-music replacement as data/music/trackNN.ogg.

Turrets (turret_breach, turret_base, turret_driver): the gun turns to where its infantry driver aims and fires rockets; kill the driver to stop it.

Props and effects: exploding barrels (misc_explobox, chain reactions), waving banners, corpses, the satellite dish, flying Strogg ships along their path_corners, func_timer, target_splash sparks, target_laser beams, and Quake 2's animated, skin-fading explosion model.

Help computer (F1) with the original help.pcx, level name, primary / secondary objectives and kills / goals / secrets, and an intermission at info_player_intermission before the next unit loads.

Particles batched into one scene (camera-facing quads with per-vertex colour / alpha and a soft round sprite): bullet impacts, blood, blaster sparks, splashes, rail trails, BFG blasts, teleport fountains.

Savegames (F6 / F9 quick save / load, save / load <name> in the console): the whole level state as JSON in the user config directory (castle-config:/saves/) — player, inventory, monsters, items, doors / plats / trains, barrels, ships, triggers, counters, timers, lasers, speakers, switchable lights, objectives.

Drop-down console, menu with the map list read from the loaded PAKs, and a headless autotest / demo-script harness.

Random levels (Random Level in the menu, randmap [seed] in the console): every seed makes its own level, built with classic Quake / Doom layout rules. Rooms of varied size are linked into loops, not dead-end trees. Low corridors climb on slopes between high rooms, and windows look from one area into another. Big rooms get pillars for cover, raised platforms, sunken pools or slime and lava pits, some rooms open to the sky (big ones become outdoor areas with grass or rock and rolling ground), some corridors have doors, rooms far higher or lower are reached by lifts or ladders, and the exit is locked behind a switch or a blue key somewhere along the way; often the blue key lies in a vault that only the red key opens. Monsters grow tougher along the way, and some only appear on harder skills or wait in ambush. Weapons come in order of strength, with ammo after them and health after the fights. There is a secret room with a teleporter back to the start, and the exit leads to the next random level. Levels are compiled at runtime into real Quake 2 maps (QuakeBspBuilder: BSP tree, brushes for collision, lightmaps, visibility), so everything in the game works in them.

Level editor (Level Editor in the menu, editor in the console): a top-down grid to paint walls and floors and to raise or lower floors and ceilings. You can add doors, lifts, buttons that open doors (switch channels), doors locked with a blue or red key, ladders, ramps (real slopes), breakable glass windows, water, slime and lava, rolling hills for outdoor areas, open cells to the sky, pick texture themes (with the full game, every texture set of its PAKs becomes a theme too), and place the player start, lights, monsters, weapons, ammo, health, armor, barrels, keys, teleporters (each goes to the destination of the same number) and the exit. It has undo, can generate a random level to start from, and saves and loads levels (castle-config:/levels/<name>.json). Play compiles the level and drops you into it at once; Export writes the Quake 2 .bsp (castle-config:/maps/<name>.bsp).

Working in the Castle Game Engine editor

The project follows the structure of CGE's own templates (3d_fps_game) and the examples/advanced_editor/custom_component sample:

Key Action

W, A, S, D / Arrows Move / strafe

Mouse Look

Left Mouse / Ctrl (hold) Fire

Space / C Jump / Crouch

E Use (doors, buttons)

1 .. 9, 0 / Mouse wheel Select weapon (Blaster .. BFG10K)

G Hand grenades

F1 Help computer (objectives, kills / goals / secrets)

F6 / F9 Quick save / quick load

F12 Screenshot

~ Console (map, maps, save, load, god, give all, give quad, give invulnerability, noclip, notarget, kill, fps, markers, novis, skill, lightstyle, record <name> / stop, spawn <class> [key value]..., sky <name> [rotate [x y z]], randmap [seed], editor [command], quit, help)

F8 (debug build) CGE inspector: hierarchy and live properties

Level editor Left mouse paints with the tool (drag to paint), right erases, middle (or Alt + left) picks a cell's heights and theme; 1–0 tools (Floor, Wall, Raise, Lower, Ceil+, Ceil-, Sky, Theme, Entity, Erase), O door, U water (V / B depth), H lift (, / . height), J button, C switch channel, M slime, I lava, R ladder, K key door (Y blue / red key), Hills, Ramp, Window (toolbar), PageUp / PageDown brush floor, Home / End brush ceiling, T theme, Q / E turn the entity, [ / ] entity type, arrows / WASD pan, wheel / + / - zoom, F fit, Ctrl+Z undo, G generate, P play, Ctrl+S save, L load the next saved level, N new, X export, Escape back to the menu

Escape Menu: Single Player (choose Easy / Medium / Hard / Nightmare), Map Warp, Options (camera, mouse sensitivity, invert mouse, view bob, field of view, sound and music volume, Controls to rebind keys)

| Touch (phones, tablets; --touch on desktop) | Left thumb anywhere on the left 40 % of the screen: move stick; drag on the right: look; buttons FIRE, JUMP, DUCK, USE, WPN (next weapon), MENU; in menus tap a row to select it, tap it again to activate it (or change its value: left half down, right half up); the Android back button is Escape | | Gamepad | Left stick move, right stick look, right trigger fire, A jump, B / left trigger crouch, X use, Y hand grenades, bumpers / D-pad up-down weapons, Menu menu, View help computer; in menus D-pad / left stick, A select, B back |

The movement, jump, crouch, use, fire, grenade and help keys above are the defaults; rebind them in Options → Controls. Options are saved with CGE's UserConfig and restored on the

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →