Post-apocalyptic garage
EARN TO DIE 2012
Level 2 — Desert Dash · code port of the decompiled AS3
$0
Best distance: 0 m
Selected car — original sprite
CAR 1 — “CAR3” (template Car3 / Car2Desc)
—
Goal: reach the finish at 26,779 (the flag stands at 27,279 — per the original rule the run completes 500 before it). The stock car is weak on purpose; earn, upgrade, push further.
↑/W gas · ←/→ or A/D tilt · X / Ctrl boost · gun auto-fires when installed (original has no fire button) · P pause. Touch buttons appear on phones.
FUEL
4.0
SPEED
0
$0
0 m · ☠ 0

PAUSED

RUN OVER

README — what was ported, and the one adaptation

This build is a direct port of the decompiled ActionScript 3 of Earn to Die 2012 (Level 2 “Desert Dash”: driving + settlement + garage). The car's numbers, formulas and logic are the originals, read from the decompiled code — not hand-tuned approximations. The previous recreation used constructor defaults (torque 300, fuel 100, wrong price table); every one of those values is corrected here from source. All three playable cars (Car3 / Car5 / Car6) are implemented from their templates, upgrade data and garage descs; the art is the SWF's own sprite renders.

Progression is the original design — not a bug: the stock Car5 cannot win Level 2. It must earn money by driving, upgrade, and push further; a fully upgraded Car5 wins Level 2, and a fully upgraded Car6 wins it too. The stock car's short range (stock Car5 runs out of fuel at ~19.3 km in this port — server-measured 2026-12-01, gas-only autodrive, fuel 22 (the old “~11.5 km” was a stale pre-fix number)) is the original earn–upgrade–retry loop, and no “extra fuel” or other deviation has been added to change it.

Decompiled files ported

FileWhat it contributed
CarBehaviour.as (736 lines)The car: ProcessAcceleration (motor torque formula, 0.8/0.2 front/rear share, torqueF curve, direct chassis force, fuel-burn formula with airF/accF/burnF), ProcessTilt (Δω kicks + in-air auto-level), ProcessBoost, ProcessSuperBrake, AlignToLandscape, CreateWheels. GetSlipTorqueMultipler stub = 1; ProcessSpikes/SetWheelFrictionBase/SetMaxVelocityToSlip are empty stubs in the original and are no-ops here.
Application_Templates_xml.asTemplates Car3, Car5, Car6 (GameUtils.m_carMappings=[3,5,6]): chassis/bumper polygons, densities, frictions, dampings, tiltImpulse (11 / 40 / 70), boostForce ((1200,0) / (3200,0) / (6000,0)), gunImpulse ((2500,500) / (3000,600) / (3500,700)), reloads (0.2s/1.5s, 0.7s/0.7s, 0.5s/0.5s), chain 1. Car3UpgradeData: engineTorque [400,500,570], topSpeed 75, wheelSpring [7,8,7], fuelBase 4 / fuelFactor 0.8, boostBase 2 / 0.3, ammoBase 3 / 2. Car5UpgradeData: torque [1800,1950,2100], topSpeed 70, fuelBase 22 / 0.31, ammoBase 5 / 2. Car6UpgradeData: torque [4000,4400,4800], topSpeed 75, fuelBase 23 / 0.35, ammoBase 6 / 2. Spikes polygons from Car5SpikesData / Car6SpikesData (Car3 has no SpikesData template — placeholder blade strip, see below).
EarnToDie_2/GameUtils.asCreateCar (stock: motorTorque 400×1×1×1×0.98 = 392, motorSpeed 75, topSpeedTorqueFactor 0.5, spring 7, fuel 4), car mappings, torque/fuel multipliers (=1 on level 2), DimensionsMultipler 10 / Sq 100.
FGKit/Physics/PhysicalBodyNape.as + PhysicalWorldNape.as + PhysicalWheelJointNape.asThe physics façade being re-implemented on planck.js: PhysicsScale 0.25, ProcessDensity (d × 1000 × 1/100 = d×10), ApplyForce unscaled, ApplyTorque as an angular-velocity kick (ω += t/inertia), ProcessDamping per step, wheel joint = PivotJoint + LineJoint + MotorJoint.
EarnToDie_2/GameLogic.asGame loop and status flow (PLAYING → PRE_REACHED 3.5 s → REACHED / FAILED), camera (car + (100,−50)), input keys, SetPhysicsSteps(33), DensityMultipler init, OnOutOfFuel / OnZombieRagdollized / OnObstacleBroken hooks.
FGKit/World/World.as + FGKit/MainTimer.asFixed dt 1/30 per frame; 33 physics substeps per frame; per substep: step (4 velocity + 4 position iterations) + damping, then every entity's OnAfterPhysicsStep.
EarnToDie_2/FailChecker.asFail rules verbatim: retreat 200 px behind max X; low-speed (vx<20, |vy|<70) timer — 3 s with fuel, 0.4 s without; “Too slow!” at timer > 0.3.
EarnToDie_2/LevelState.asWorld gravity (0, 650) px/s² → (0, 162.5) in physics units.
LandscapeBehaviour.asTerrain: Catmull-Rom spline (builder JSON's 74 sampled points for L2), static polygon chunks cut every 2000 px (density 0, friction 1, bounce 0.5), GetDataByX used by AlignToLandscape.
EarnToDie_2/MoneyManager.as + MoneyManager_Money.asMoney: int((d·A)² + B). Level 2 uses row m_levels[GetLevelId()−1] = m_levels[0] (the off-by-one): A=0.00065, B=22, zombie $2, completion $100. Win distance = target − spawnerX; fail distance = maxCarX − spawnerX.
EarnToDie_2/Upgrades/Car2Desc.as + Car4Desc.as + Car5Desc.as + UpgradesDesc.asGarage prices per car. Car3 (Car2Desc): engine $0/$750/$2750, gearbox $0/$900/$3000, wheels $0/$700/$1800, fuel refills $100–$350, boost $1500 (+refills $250–$500), gun $2000 (+ammo $120–$350), spikes $1000/$2500. Car5 (Car4Desc): engine $0/$18,000/$65,000, gearbox $0/$20,000/$70,000, wheels $0/$16,000/$45,000, fuel $2000–$7000, boost $40,000 (+refills $6000–$12000), gun $50,000 (+ammo $2000–$8000), spikes $25,000/$60,000. Car6 (Car5Desc): engine $0/$90,000/$330,000, gearbox $0/$100,000/$350,000, wheels $0/$85,000/$200,000, fuel $8000–$30,000, boost $200,000 (+refills $30,000–$60,000), gun $250,000 (+ammo $12,000–$45,000), spikes $120,000/$300,000. Car prices (GetCarDescIndex = template−1): Car5 $500, Car6 $2,500 — the audit's "$2,500 / $1,500,000" indexed m_cars by template number and was wrong; the code wins.
EarnToDie_2/CollisionGroups.asCollision bit flags and per-shape group/mask (chassis ALL, bumpers/wheels/spikes exclude landscape/car as in source), mapped to planck category/mask bits (32-bit NOT masked to 16 bits).
StoneBehaviour.asStones are static bodies, collision group CG_LANDSCAPE, friction 1, bounce 0.5, never breakable — they are terrain bumps, not smashables. Placement uses the level-XML rotation per stone (fixed 2026-11-30: the port previously dropped rotation, so stones lay flat across the slope and their downhill edge jutted ~20px above the 40% first-hill grade as a wedge that pitched the car nose-down to a stall at the zombie pile). Art is the original FFDec stone renders (flat slivers: only the top sits above the terrain).
FGKit/Utils.asClamp, AdvanceNumber, NormalizeAngle, ConvexDecomposition (replaced by ear-clip triangulation into convex triangles).
CarGraphic.as + structure/movie.xmlWheel positions per wheel type (type 1: front (47.35, 2.6), rear (−42.4, 2.6); type 2/3 in code) and wheel radii 12/13/15 from FFDec sprite renders.
Levels_level2.as (177 entity tags → 509 positions, parsed directly)Level 2 data: 74 terrain points, car spawner (72.6, 1934.7), goal (27278.6, 1269.5) → win target = goal.x − 500, 3 explosive barrels (8747 / 11661 / 11796), 66 zombies (28 WalkingZombie_0 + 27 BigWalkingZombie + 6 StayingZombie + 5 BigStayingZombie), 171 breakables (Box 77, Box2 55, Board 22, Box_paper 15, Box3 2) + 47 stones (Stone 10, Stone_1_2 7, Stone_2 14, Stone_2_1 8, Stone_3 8) — the old "218 smashables" lumped stones in with breakables; stones are static terrain, not breakable.
ObstacleBehaviour.as + EarnToDie_2/ImpulseMessage.as + DensitiesManager_Densities.asBreak rule: m_breakImpulse = 10 × breakImpulse × spikesMassFactor × breakForceFactor × 1.6 (contact normal impulse; the port uses a per-kind contact-speed proxy calibrated from this formula — see code — plus push-to-break: sustained driving into an obstacle breaks it after 0.25 s × (m_breakImpulse / Box), because the original breaks on accumulated impulse, not impact speed alone; the 0.25 s base is feel-tuned). L2 factors: Box 1.8/1.7, Box2 1.7/1.6, Box_paper 1.5/1.7, Board 1.1/1.8, Box3 0.7/0.7, Big_Box 0.6/0.6 (densityFactor/breakForceFactor); densities = template × factor × spikesMassFactor. Disable timer: chassis contact starts it; after disableTime (4 s) with car vx > 20 the obstacle stops colliding with the car. Under-car: contact point above COM − halfWidth + 3 → broken after 0.5 s. Barrels are explosive (density 7, breakImpulse 40, explosionImpulse 300, explosionRadius 150): radius in game px = 150 × DimensionsMultipler = 1500, impulse falls off linearly (1 − d/r), receiver scales ×10. Barrels give no fuel.
EarnToDie_2/Car/CarWeapon.asGun (only if bought): auto-fires — CarBehaviour.Update calls m_weapon.Update(dt) every frame and m_enabled is always true (no fire-button gate exists); the old "Space fires / no auto-fire" claim was wrong. Ammo decrements only when Shoot() returns true. Target: first registered zombie with dx in [100, Clamp(200 + vx×0.05 + chainPos×100, 250, 600)] and aim within 20° of the car's forward direction (dot ≥ cos 20°); muzzle = car transform of (0, 10). Chain: short reload inside a chain, long reload after the last shot; chain resets if idle longer than the long reload. Shot zombies ragdoll after Clamp(8 − carVx×0.005, 0, 8) ticks, with the gun velocity kick (ApplyShootImpulse: Random(0.3×Ix, Ix) + carVx, Random(−Iy, 0)) applied when the ragdoll is created. Quirk ported: SetImpulse sets impulse.y = impulse.x, so Car3's gun impulse is (2500, 2500), not (2500, 500).
EarnToDie_2/RapidManager.as + StuntManager.asSlow-mo: factor 1 → 7 at rate dt×30, decays to 1 at dt×5; world dt is divided by the factor. Trigger is the verbatim StuntManager formula: hits feed a chain (zombie ragdoll +5, obstacle broken +1, only if within carX−250..carX+500; the chain resets if no hit for 0.1 s); probability is checked every 0.03 s and is Clamp((chain − 5) × min(timeSinceLastStunt, 20) × 0.0005, 0, 0.1), zero unless ≥ 7 s since the last stunt — so slow-mo is rare (a single zombie gives chain 5 → probability 0). The old "every kill triggers slow-mo" rule and the "probability not recoverable" claim were both wrong. Barrel explosions do not feed the chain directly (the private OnObstacleExploded is never called); the barrel's break feeds +1.
Zombie / ragdoll behaviours (WalkingZombieBehaviour.as, StayingZombieBehaviour.as, GameUtils.CreateRagdoll)Walking zombies (28 small + 27 big): kinematic sensor bodies (mask CG_CAR only), walk left at 30 / 40 px/s glued to the terrain, ragdoll on car contact (only while controls are enabled) or after the shot delay. Staying zombies (6 small + 5 big): dynamic triangle bodies (density 35 / 30, friction 1, bounce 0.001), ragdoll on car contact or when knocked unstable (|vx|+|vy|+|spin|×10 > 30 with the stabilize timer, > 150, or > 300). Shot zombies of both kinds ragdoll after the tick delay. Ragdoll = single dynamic body (the original is multi-part; see unknowns) with the ragdoll template density (ZombieRagdoll 7 / BigZombieRagdoll 25 × L2 factors 1.8 / 1.6); shot ragdolls do not collide with the car and get the gun velocity kick. Walking zombies ignore barrel explosions. Art is the original FFDec zombie renders (small zombies use the big render scaled 0.85 — the small renders are not in the export).

The one adaptation: the physics-engine layer (Nape → planck.js)

Genuinely unknown / approximated (stated, not silently substituted)

Test hooks: window.__ETD (state / startDrive / setSave / buyUpgrade / buyCar / setCar / setKey), ?autodrive=1, ?maxup=1 (fully upgrades the selected car), ?car=0|1|2 (select Car3/Car5/Car6 for the run). Original sounds (engine, explosion, splat, box break, buy, Blues music), the Arizona/garage backdrops and the car/zombie/obstacle sprites are the SWF's own assets.