with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure Flight_Sim is type Vector3 is record X : Float := 0.0; Y : Float := 0.0; Z : Float := 0.0; end record; function "+" (A, B : Vector3) return Vector3 is begin return (A.X + B.X, A.Y + B.Y, A.Z + B.Z); end; function "*" (A : Vector3; S : Float) return Vector3 is begin return (A.X * S, A.Y * S, A.Z * S); end; Position : Vector3 := (0.0, 0.0, 0.0); Velocity : Vector3 := (0.0, 0.0, 0.0); Flying : Boolean := False; Speed : Float := 60.0; Input : Character; begin Put_Line("=== Ada Flight Simulation ==="); Put_Line("F = toggle flight, WASD = move, Space = up, C = down, Q = quit"); loop Put("Input: "); Get(Input); if Input = 'F' or else Input = 'f' then Flying := not Flying; if Flying then Put_Line("Flight enabled"); else Put_Line("Flight disabled"); Velocity := (0.0, 0.0, 0.0); end if; end if; if Flying then declare Move : Vector3 := (0.0, 0.0, 0.0); begin case Input is when 'W' | 'w' => Move.Z := Move.Z + 1.0; when 'S' | 's' => Move.Z := Move.Z - 1.0; when 'A' | 'a' => Move.X := Move.X - 1.0; when 'D' | 'd' => Move.X := Move.X + 1.0; when ' ' => Move.Y := Move.Y + 1.0; -- Space when 'C' | 'c' => Move.Y := Move.Y - 1.0; when others => null; end case; Velocity := Move * Speed; Position := Position + Velocity * 0.016; -- simulate ~60 FPS end; end if; Put("Position => X: "); Put(Position.X, Fore => 1, Aft => 2, Exp => 0); Put(" Y: "); Put(Position.Y, Fore => 1, Aft => 2, Exp => 0); Put(" Z: "); Put(Position.Z, Fore => 1, Aft => 2, Exp => 0); New_Line; exit when Input = 'Q' or else Input = 'q'; end loop; Put_Line("Simulation ended."); end Flight_Sim;