Subversion Repositories spacemission

Rev

Rev 4 | Rev 7 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit GamMain;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, MMSystem, Dialogs,
  7.   StdCtrls, ExtCtrls, Menus, DIB, DXClass, DXSprite, DXDraws, DXInput, DXSounds,
  8.   INIFiles, ShellAPI, wininet{$IF CompilerVersion >= 23.0}, Winapi.DirectDraw,
  9.   System.UITypes{$ELSE}, DirectX{$IFEND};
  10.  
  11. type
  12.   TGameScene = (
  13.     gsNone,
  14.     gsTitle,
  15.     gsMain,
  16.     gsGameOver,
  17.     gsNewLevel,
  18.     gsWin
  19.   );
  20.  
  21.   TGameInterval = (
  22.     giMittel,
  23.     giLeicht,
  24.     giSchwer,
  25.     giMaster
  26.   );
  27.  
  28.   TMusicTrack = (
  29.     mtNone,
  30.     mtGame,
  31.     mtBoss,
  32.     mtScene,
  33.     mtTitle
  34.   );
  35.  
  36.   {TSoundFile = (
  37.     sfNone,
  38.     sfSceneMov,
  39.     sfExplosion,
  40.     sfHit,
  41.     sfShoot,
  42.     sfDanger,
  43.     sfEnde,
  44.     sfFrage,
  45.     sfLevIntro
  46.   );}
  47.  
  48.   TBackground = class(TBackgroundSprite)
  49.   private
  50.     FSpeed: Double;
  51.   protected
  52.     procedure DoMove(MoveCount: Integer); override;
  53.   end;
  54.  
  55.   TBackgroundSpecial = class(TBackgroundSprite)
  56.   private
  57.     FSpeed: Double;
  58.   protected
  59.     procedure DoMove(MoveCount: Integer); override;
  60.   end;
  61.  
  62.   TExplosion = class(TImageSprite)
  63.   private
  64.     FCounter: Integer;
  65.   protected
  66.     procedure DoMove(MoveCount: Integer); override;
  67.   public
  68.     constructor Create(AParent: TSprite); override;
  69.   end;
  70.  
  71.   TPlayerSprite = class(TImageSprite)
  72.   private
  73.     FCounter: Integer;
  74.     FMode: Integer;
  75.     FTamaCount: Integer;
  76.     FOldTamaTime: Integer;
  77.   protected
  78.     procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
  79.     procedure DoMove(MoveCount: Integer); override;
  80.   public
  81.     constructor Create(AParent: TSprite); override;
  82.     procedure FlyAway;
  83.   end;
  84.  
  85.   TTamaSprite = class(TImageSprite)
  86.   private
  87.     FPlayerSprite: TPlayerSprite;
  88.   protected
  89.     procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
  90.     procedure DoMove(MoveCount: Integer); override;
  91.   public
  92.     constructor Create(AParent: TSprite); override;
  93.     destructor Destroy; override;
  94.   end;
  95.  
  96.   TEnemy = class(TImageSprite)
  97.   private
  98.     FCounter: Integer;
  99.     FLife: integer;
  100.     FMode: Integer;
  101.     procedure Hit; virtual;
  102.   protected
  103.     procedure HitEnemy(ADead: Boolean); virtual;
  104.   public
  105.     constructor Create(AParent: TSprite); override;
  106.     destructor Destroy; override;
  107.   end;
  108.  
  109.   TEnemyTama = class(TImageSprite)
  110.   private
  111.     FPlayerSprite: TSprite;
  112.   protected
  113.     procedure DoMove(MoveCount: Integer); override;
  114.   public
  115.     constructor Create(AParent: TSprite); override;
  116.   end;
  117.  
  118.   TEnemyMeteor = class(TEnemy)
  119.   protected
  120.     procedure DoMove(MoveCount: Integer); override;
  121.     procedure HitEnemy(ADead: Boolean); override;
  122.   public
  123.     constructor Create(AParent: TSprite); override;
  124.   end;
  125.  
  126.   TEnemyUFO = class(TEnemy)
  127.   protected
  128.     procedure DoMove(MoveCount: Integer); override;
  129.     procedure HitEnemy(ADead: Boolean); override;
  130.   public
  131.     constructor Create(AParent: TSprite); override;
  132.   end;
  133.  
  134.   TEnemyUFO2 = class(TEnemy)
  135.   private
  136.     FCounter: Integer;
  137.     FTamaCount: Integer;
  138.     FOldTamaTime: Integer;
  139.   protected
  140.     procedure DoMove(MoveCount: Integer); override;
  141.     procedure HitEnemy(ADead: Boolean); override;
  142.   public
  143.     constructor Create(AParent: TSprite); override;
  144.   end;
  145.  
  146.   TEnemyAttacker = class(TEnemy)
  147.   protected
  148.     procedure DoMove(MoveCount: Integer); override;
  149.     procedure HitEnemy(ADead: Boolean); override;
  150.   public
  151.     constructor Create(AParent: TSprite); override;
  152.   end;
  153.  
  154.   TEnemyAttacker2 = class(TEnemy)
  155.   private
  156.     FCounter: Integer;
  157.     FTamaF: Integer;
  158.     FTamaT: Integer;
  159.     FPutTama: Boolean;
  160.   protected
  161.     procedure DoMove(MoveCount: Integer); override;
  162.     procedure HitEnemy(ADead: Boolean); override;
  163.   public
  164.     constructor Create(AParent: TSprite); override;
  165.   end;
  166.  
  167.   TEnemyAttacker3 = class(TEnemy)
  168.   private
  169.     FCounter: Integer;
  170.     FTamaCount: Integer;
  171.     FOldTamaTime: Integer;
  172.   protected
  173.     procedure DoMove(MoveCount: Integer); override;
  174.     procedure HitEnemy(ADead: Boolean); override;
  175.   public
  176.     constructor Create(AParent: TSprite); override;
  177.   end;
  178.  
  179.   TEnemyBoss = class(TEnemy)
  180.   private
  181.     FCounter: Integer;
  182.     FTamaF: Integer;
  183.     FTamaT: Integer;
  184.     FPutTama: Boolean;
  185.     waiter1, waiter2: integer;
  186.   protected
  187.     procedure DoMove(MoveCount: Integer); override;
  188.     procedure HitEnemy(ADead: Boolean); override;
  189.   public
  190.     constructor Create(AParent: TSprite); override;
  191.   end;
  192.  
  193.   TNothing = class(TImageSprite);
  194.  
  195.   TSpriteClass = class of TSprite;
  196.  
  197.   TEnemyAdvent = record
  198.     spriteClass: TSpriteClass;
  199.     x: extended;
  200.     y: extended;
  201.     lifes: integer;
  202.   end;
  203.  
  204.   TMainForm = class(TDXForm)
  205.     MainMenu: TMainMenu;
  206.     Spiel: TMenuItem;
  207.     GameStart: TMenuItem;
  208.     GamePause: TMenuItem;
  209.     Beenden: TMenuItem;
  210.     Einstellungen: TMenuItem;
  211.     OptionFullScreen: TMenuItem;
  212.     OptionMusic: TMenuItem;
  213.     Leer2: TMenuItem;
  214.     Leer4: TMenuItem;
  215.     Hilfe: TMenuItem;
  216.     OptionSound: TMenuItem;
  217.     Leer3: TMenuItem;
  218.     Spielstand: TMenuItem;
  219.     Leer5: TMenuItem;
  220.     Neustart: TMenuItem;
  221.     OptionBreitbild: TMenuItem;
  222.     Spielgeschwindigkeit: TMenuItem;
  223.     Leicht: TMenuItem;
  224.     Mittel: TMenuItem;
  225.     Schwer: TMenuItem;
  226.     Informationen: TMenuItem;
  227.     Leer6: TMenuItem;
  228.     Leer1: TMenuItem;
  229.     Cheat: TMenuItem;
  230.     CheckUpdates: TMenuItem;
  231.     Master: TMenuItem;
  232.     procedure DXDrawFinalize(Sender: TObject);
  233.     procedure DXDrawInitialize(Sender: TObject);
  234.     procedure FormCreate(Sender: TObject);
  235.     procedure DXTimerTimer(Sender: TObject; LagCount: Integer);
  236.     procedure DXTimerActivate(Sender: TObject);
  237.     procedure DXTimerDeactivate(Sender: TObject);
  238.     procedure OptionFullScreenClick(Sender: TObject);
  239.     procedure DXDrawInitializing(Sender: TObject);
  240.     procedure GameStartClick(Sender: TObject);
  241.     procedure GamePauseClick(Sender: TObject);
  242.     procedure BeendenClick(Sender: TObject);
  243.     procedure OptionSoundClick(Sender: TObject);
  244.     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  245.     procedure OptionMusicClick(Sender: TObject);
  246.     procedure SpielstandClick(Sender: TObject);
  247.     procedure NeustartClick(Sender: TObject);
  248.     procedure OptionBreitbildClick(Sender: TObject);
  249.     procedure LeichtClick(Sender: TObject);
  250.     procedure MittelClick(Sender: TObject);
  251.     procedure SchwerClick(Sender: TObject);
  252.     procedure FormShow(Sender: TObject);
  253.     procedure InformationenClick(Sender: TObject);
  254.     procedure CheatClick(Sender: TObject);
  255.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  256.     procedure FormDestroy(Sender: TObject);
  257.     procedure CheckUpdatesClick(Sender: TObject);
  258.     procedure MasterClick(Sender: TObject);
  259.   private
  260.     ProgrammGestartet: boolean;
  261.     FInterval: TGameInterval;
  262.     FScene: TGameScene;
  263.     FMusic: TMusicTrack;
  264.     FBlink: DWORD;
  265.     FBlinkTime: DWORD;
  266.     FFrame, FAngle, FCounter, FEnemyAdventPos: Integer;
  267.     PlayerSprite: TPlayerSprite;
  268.     procedure StartScene(Scene: TGameScene);
  269.     procedure EndScene;
  270.     procedure BlinkStart;
  271.     procedure BlinkUpdate;
  272.     procedure StartSceneTitle;
  273.     procedure SceneTitle;
  274.     procedure EndSceneTitle;
  275.     procedure StartSceneMain;
  276.     procedure SceneMain;
  277.     procedure EndSceneMain;
  278.     procedure StartSceneGameOver;
  279.     procedure SceneGameOver;
  280.     procedure EndSceneGameOver;
  281.     procedure StartSceneWin;
  282.     procedure SceneWin;
  283.     procedure EndSceneWin;
  284.     procedure StartSceneNewLevel;
  285.     procedure SceneNewLevel;
  286.     procedure EndSceneNewLevel;
  287.   public
  288.     FNextScene: TGameScene;
  289.     FScore: Integer;
  290.     FNotSave: boolean;
  291.     FLife: integer;
  292.     FLevel: integer;
  293.     FMenuItem: integer;
  294.     FBossLife: integer;
  295.     FRestEnemys: integer;
  296.     FCheat: boolean;
  297.     { VCL-Ersatz }
  298.     dxdraw: TDxDraw;
  299.     imagelist: TDxImageList;
  300.     spriteengine: tdxspriteengine;
  301.     dxsound: tdxsound;
  302.     wavelist: tdxwavelist;
  303.     dxinput: tdxinput;
  304.     dxtimer: tdxtimer;
  305.     { Level-Routinen }
  306.     procedure NewLevel(lev: integer);
  307.     procedure DeleteArray;
  308.     { MCI-Routinen }
  309.     function StatusMusic(Name: TMusicTrack): string;
  310.     procedure PlayMusic(Name: TMusicTrack);
  311.     //procedure StopMusic(Name: TMusicTrack);
  312.     procedure PauseMusic(Name: TMusicTrack);
  313.     procedure ResumeMusic(Name: TMusicTrack);
  314.     procedure DestroyMusic(Name: TMusicTrack);
  315.     procedure OpenMusic(Name: TMusicTrack);
  316.     { Sound-Routinen }
  317.     function SoundKarte: boolean;
  318.     procedure PlaySound(Name: string; Wait: Boolean);
  319.     { Initialisiations-Routinen }
  320.     procedure DXInit;
  321.     procedure SoundInit;
  322.     procedure MusicInit;
  323.     { Einstellungs-Routinen }
  324.     procedure LoadOptions;
  325.     procedure WriteOptions;
  326.     { Farb-Routinen }
  327.     function ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
  328.     procedure PalleteAnim(Col: TRGBQuad; Time: Integer);
  329.   end;
  330.  
  331. var
  332.   MainForm: TMainForm;
  333.  
  334. const
  335.   // TODO: ini file
  336.   conleicht = 650 div 60; // 10
  337.   conmittel = 1000 div 60; // 16
  338.   conschwer = 1350 div 60; // 22
  339.   conmaster = 2000 div 60; // 33
  340.   lives = 6;
  341.  
  342. implementation
  343.  
  344. uses
  345.   GamSplash, GamSpeicherung, ComInfo, GamCheat, Global;
  346.  
  347. resourcestring
  348.   FileError = 'Die Datei kann von SpaceMission nicht geöffnet werden!';
  349.  
  350. {$R *.DFM}
  351.  
  352. var // TODO: irgendwo hinpacken. irgendwo!!!
  353.   EnemyAdventTable: array[0..9999] of TEnemyAdvent; // TODO: dyn
  354.   Crash2, ec: integer;
  355.   BossExists, Crash, crashsound: boolean;
  356.   pos: array[1..4] of integer;
  357.   enemys: array[1..27] of TSpriteClass;
  358.   levact: integer;
  359.  
  360. const
  361.   DXInputButton = [isButton1, isButton2, isButton3,
  362.     isButton4, isButton5, isButton6, isButton7, isButton8, isButton9, isButton10, isButton11,
  363.     isButton12, isButton13, isButton14, isButton15, isButton16, isButton17, isButton18,
  364.     isButton19, isButton20, isButton21, isButton22, isButton23, isButton24, isButton25,
  365.     isButton26, isButton27, isButton28, isButton29, isButton30, isButton31, isButton32];
  366.  
  367. const // TODO: Auch für Enemies
  368.   PLAYER_MODE_NORMAL = 0;
  369.   PLAYER_MODE_DEAD = 1;
  370.   PLAYER_MODE_DEAD_VANISHED = 2;
  371.   PLAYER_MODE_FLYAWAY = 3;
  372.   PLAYER_MODE_ENTER = 4;
  373.  
  374.   DEFAULT_ANIMSPEED = 15/1000;
  375.  
  376. // TODO: Code komplett überarbeiten. Bessere Ableitungen machen
  377.  
  378. constructor TPlayerSprite.Create(AParent: TSprite);
  379. begin
  380.   inherited Create(AParent);
  381.   Image := MainForm.ImageList.Items.Find('Machine');
  382.   Width := Image.Width;
  383.   Height := Image.Height;
  384.   X := -70{20};
  385.   Y := mainform.dxdraw.surfaceHeight / 2 - (height / 2);
  386.   Z := 2;
  387.   AnimCount := Image.PatternCount;
  388.   AnimLooped := True;
  389.   AnimSpeed := DEFAULT_ANIMSPEED;
  390.   FMode := PLAYER_MODE_ENTER;
  391. end;
  392.  
  393. procedure TPlayerSprite.DoCollision(Sprite: TSprite; var Done: Boolean);
  394. begin
  395.   if mainform.FCheat then exit;
  396.   if (Sprite is TEnemy) or (Sprite is TEnemyTama) then
  397.   begin
  398.     if not crash then
  399.     begin
  400.       dec(MainForm.FLife);
  401.       Crash := true;
  402.       if MainForm.Flife=0 then
  403.       begin
  404.         MainForm.PlaySound('Explosion', false);
  405.         Collisioned := false;
  406.         FCounter := 0;
  407.         FMode := PLAYER_MODE_DEAD;
  408.         Done := false;
  409.         Image := MainForm.ImageList.Items.Find('Explosion');
  410.         Width := Image.Width;
  411.         Height := Image.Height;
  412.         AnimCount := Image.PatternCount;
  413.         AnimLooped := False;
  414.         AnimSpeed := DEFAULT_ANIMSPEED;
  415.         AnimPos := 0;
  416.       end;
  417.     end
  418.     else
  419.     begin
  420.       if not crashsound then
  421.       begin
  422.         MainForm.PlaySound('Hit', False);
  423.         crashsound := true;
  424.       end;
  425.     end;
  426.   end;
  427. end;
  428.  
  429. procedure TPlayerSprite.DoMove(MoveCount: Integer);
  430. const
  431.   WegduesKonstante = 1.75;
  432. begin
  433.   inherited DoMove(MoveCount);
  434.   if FMode=PLAYER_MODE_NORMAL then
  435.   begin
  436.     if isUp in MainForm.DXInput.States then Y := Y - (250/1000)*MoveCount;
  437.     if isDown in MainForm.DXInput.States then Y := Y + (250/1000)*MoveCount;
  438.     if isLeft in MainForm.DXInput.States then X := X - (250/1000)*MoveCount;
  439.     if isRight in MainForm.DXInput.States then X := X + (250/1000)*MoveCount;
  440.     if X<0 then X := 0;
  441.     if X>mainform.dxdraw.surfacewidth-Width then X := mainform.dxdraw.surfacewidth-Width;
  442.     if Y<0 then Y := 0;
  443.     if Y>mainform.dxdraw.surfaceheight-Height then Y := mainform.dxdraw.surfaceheight-Height;
  444.     if isButton1 in MainForm.DXInput.States then
  445.     begin
  446.       if (FTamaCount<8) and (FCounter-FOldTamaTime>=100) then
  447.       begin
  448.         Inc(FTamaCount);
  449.         with TTamaSprite.Create(Engine) do
  450.         begin
  451.           FPlayerSprite := Self;
  452.           X := Self.X+Self.Width;
  453.           Y := Self.Y+Self.Height div 2-Height div 2;
  454.           Z := 10;
  455.         end;
  456.         FOldTamaTime := FCounter;
  457.       end;
  458.     end;
  459.     Collision;
  460.   end else if FMode=PLAYER_MODE_DEAD then
  461.   begin
  462.     if FCounter>200 then
  463.     begin
  464.       FCounter := 0;
  465.       FMode := PLAYER_MODE_DEAD_VANISHED;
  466.       Visible := false;
  467.     end;
  468.   end else if FMode=PLAYER_MODE_DEAD_VANISHED then
  469.   begin
  470.     if FCounter>1500 then
  471.     begin
  472.       MainForm.FNextScene := gsGameOver;
  473.       MainForm.PlaySound('SceneMov', false);
  474.       MainForm.PalleteAnim(RGBQuad(0, 0, 0), 300);
  475.       Sleep(200);
  476.     end;
  477.   end else if FMode=PLAYER_MODE_FLYAWAY then
  478.   begin
  479.     // FUT: "Wusch" sound?
  480.     X := X + MoveCount*(300/1000) * (X/MainForm.DXDraw.Width + WegduesKonstante);
  481.     if X > MainForm.DXDraw.Width+Width then
  482.     begin
  483.       Dead;
  484.       inc(mainform.FLevel);
  485.       MainForm.FNextScene := gsNewLevel;
  486.       MainForm.PlaySound('SceneMov', false);
  487.       MainForm.PalleteAnim(RGBQuad(0, 0, 0), 300);
  488.     end;
  489.   end else if FMode = PLAYER_MODE_ENTER then
  490.   begin
  491.     X := X + MoveCount*(300/1000);
  492.     if X > 19 then FMode := PLAYER_MODE_NORMAL;
  493.   end;
  494.   inc(FCounter, MoveCount);
  495. end;
  496.  
  497. procedure TPlayerSprite.FlyAway;
  498. begin
  499.   FMode := PLAYER_MODE_FLYAWAY;
  500. end;
  501.  
  502. procedure TMainForm.DXInit;
  503. begin
  504.   try
  505.     Imagelist.Items.LoadFromFile(FDirectory+'DirectX\Graphic.dxg');
  506.     ImageList.Items.MakeColorTable;
  507.     DXDraw.ColorTable := ImageList.Items.ColorTable;
  508.     DXDraw.DefColorTable := ImageList.Items.ColorTable;
  509.     DXDraw.UpdatePalette;
  510.     OptionBreitBild.enabled := OptionFullScreen.checked;
  511.     DXDraw.Finalize;
  512.     if OptionFullScreen.Checked then
  513.     begin
  514.       if not (doFullScreen in DXDraw.Options) then StoreWindow;
  515.       DXDraw.Options := DXDraw.Options + [doFullScreen];
  516.     end else
  517.     begin
  518.       if doFullScreen in DXDraw.Options then RestoreWindow;
  519.       DXDraw.Options := DXDraw.Options - [doFullScreen];
  520.     end;
  521.     if not OptionBreitBild.checked then
  522.     begin
  523.       dxdraw.autosize := false;
  524.       dxdraw.Top := 0;
  525.       dxdraw.Left := 0;
  526.       dxdraw.width := 640;    // TODO: besser die dimensionen des fensters
  527.       dxdraw.height := 480;
  528.       dxdraw.surfacewidth := 640;
  529.       dxdraw.surfaceheight := 480;
  530.     end
  531.     else dxdraw.autosize := true;
  532.     DXDraw.Initialize;
  533.   except
  534.     //Imagelist.Items.clear;
  535.     //application.terminate;
  536.   end;
  537. end;
  538.  
  539. constructor TTamaSprite.Create(AParent: TSprite);
  540. begin
  541.   inherited Create(AParent);
  542.   Image := MainForm.ImageList.Items.Find('Bounce');
  543.   Z := 2;
  544.   Width := Image.Width;
  545.   Height := Image.Height;
  546.   AnimCount := Image.PatternCount;
  547.   AnimLooped := True;
  548.   AnimSpeed := DEFAULT_ANIMSPEED;
  549.   MainForm.PlaySound('Shoot', False);
  550. end;
  551.  
  552. destructor TTamaSprite.Destroy;
  553. begin
  554.   inherited Destroy;
  555.   Dec(FPlayerSprite.FTamaCount);
  556. end;
  557.  
  558. procedure TTamaSprite.DoCollision(Sprite: TSprite; var Done: Boolean);
  559. begin
  560.   if (Sprite is TEnemy) and (not (Sprite is TEnemyTama)) then
  561.   begin
  562.     TEnemy(Sprite).Hit;
  563.     Dead;
  564.   end;
  565.   Done := False;
  566. end;
  567.  
  568. procedure TTamaSprite.DoMove(MoveCount: Integer);
  569. begin
  570.   inherited DoMove(MoveCount);
  571.   X := X+(800/1000)*MoveCount;
  572.   if X>=mainform.dxdraw.surfacewidth then Dead;
  573.   Collision;
  574. end;
  575.  
  576. procedure TBackground.DoMove(MoveCount: Integer);
  577. var
  578.   ran: integer;
  579. begin
  580.   inherited DoMove(MoveCount);
  581.   X := X - MoveCount*(60/1000)*FSpeed;
  582.   randomize;
  583.   ran := Random(1500);
  584.   if ran = 150 then
  585.   begin
  586.     with TBackgroundSpecial.Create(mainform.SpriteEngine.Engine) do
  587.     begin
  588.       SetMapSize(1, 1);
  589.       Image := mainform.ImageList.Items.Find('Background-Planet1');
  590.       Width := Image.Width;
  591.       Height := Image.Height;
  592.  
  593.       Y := random(mainform.dxdraw.height);
  594.       X := mainform.dxdraw.width;
  595.  
  596.       ran := Random(2);
  597.       if ran = 0 then
  598.       begin
  599.         Z := -20;
  600.         FSpeed := 1.8;
  601.       end
  602.       else if ran = 1 then
  603.       begin
  604.         Z := -40;
  605.         FSpeed := 0.8;
  606.       end
  607.       else if ran = 2 then
  608.       begin
  609.         Z := -60;
  610.         FSpeed := 0.3;
  611.       end;
  612.     end;
  613.   end
  614.   else if ran = 500 then
  615.   begin
  616.     with TBackgroundSpecial.Create(mainform.SpriteEngine.Engine) do
  617.     begin
  618.       SetMapSize(1, 1);
  619.       ran := Random(4);
  620.       if ran = 0 then
  621.         Image := mainform.ImageList.Items.Find('Background-Red')
  622.       else if ran = 1 then
  623.         Image := mainform.ImageList.Items.Find('Background-Blue')
  624.       else if ran = 2 then
  625.         Image := mainform.ImageList.Items.Find('Background-Yellow')
  626.       else if ran = 3 then
  627.         Image := mainform.ImageList.Items.Find('Hintergrund-Rot');
  628.       Width := Image.Width;
  629.       Height := Image.Height;
  630.  
  631.       Y := random(mainform.dxdraw.height);
  632.       X := mainform.dxdraw.width;
  633.  
  634.       { ran := Random(2);
  635.       if ran = 0 then
  636.       begin
  637.         Z := -20;
  638.         FSpeed := 1.8;
  639.       end
  640.       else if ran = 1 then
  641.       begin
  642.         Z := -40;
  643.         FSpeed := 0.8;
  644.       end
  645.       else if ran = 2 then
  646.       begin }
  647.         Z := -60;
  648.         FSpeed := 0.3;
  649.       { end; }
  650.     end;
  651.   end;
  652. end;
  653.  
  654. procedure TBackgroundSpecial.DoMove(MoveCount: Integer);
  655. begin
  656.   inherited DoMove(MoveCount);
  657.   X := X - MoveCount*(60/1000)*FSpeed;
  658.   if X<-Width then Dead;
  659. end;
  660.  
  661. constructor TExplosion.Create(AParent: TSprite);
  662. begin
  663.   inherited Create(AParent);
  664.   mainform.PlaySound('Explosion', false);
  665.   Image := MainForm.ImageList.Items.Find('Explosion');
  666.   Width := Image.Width;
  667.   Height := Image.Height;
  668.   AnimCount := Image.PatternCount;
  669.   AnimLooped := True;
  670.   AnimSpeed := DEFAULT_ANIMSPEED;
  671.   AnimPos := Random(AnimCount);
  672. end;
  673.  
  674. procedure TExplosion.DoMove(MoveCount: Integer);
  675. begin
  676.   inherited DoMove(MoveCount);
  677.   inc(FCounter, MoveCount);
  678.   if FCounter > 2999 then dead;
  679. end;
  680.  
  681. constructor TEnemyTama.Create(AParent: TSprite);
  682. begin
  683.   inherited Create(AParent);
  684.   Image := MainForm.ImageList.Items.Find('Bounce2');
  685.   Width := Image.Width;
  686.   Height := Image.Height;
  687.   AnimCount := Image.PatternCount;
  688.   AnimLooped := True;
  689.   AnimSpeed := DEFAULT_ANIMSPEED;
  690.   MainForm.PlaySound('Shoot', False);
  691. end;
  692.  
  693. procedure TEnemyTama.DoMove(MoveCount: Integer);
  694. begin
  695.   inherited DoMove(MoveCount);
  696.   X := X - MoveCount*(600/1000);
  697.   if X<-Width then Dead;
  698. end;
  699.  
  700. procedure TEnemy.Hit;
  701. begin
  702.   Dec(FLife);
  703.   if FLife<=0 then
  704.   begin
  705.     Collisioned := False;
  706.     HitEnemy(True);
  707.   end
  708.   else
  709.     HitEnemy(False);
  710. end;
  711.  
  712. procedure TEnemy.HitEnemy(ADead: Boolean);
  713. begin
  714.   if ADead then MainForm.PlaySound('Explosion', False);
  715. end;
  716.  
  717. constructor TEnemyUFO.Create(AParent: TSprite);
  718. begin
  719.   inherited Create(AParent);
  720.   Image := MainForm.ImageList.Items.Find('Enemy-disk');
  721.   Width := Image.Width;
  722.   Height := Image.Height;
  723.   AnimCount := Image.PatternCount;
  724.   AnimLooped := True;
  725.   AnimSpeed := DEFAULT_ANIMSPEED;
  726.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  727. end;
  728.  
  729. constructor TEnemy.Create(AParent: TSprite);
  730. begin
  731.   inherited Create(AParent);
  732.   dec(mainform.FRestEnemys);
  733.   inc(ec);
  734. end;
  735.  
  736. destructor TEnemy.Destroy;
  737. begin
  738.   inherited Destroy;
  739.   dec(ec);
  740. end;
  741.  
  742. procedure TEnemyUFO.HitEnemy(ADead: Boolean);
  743. begin
  744.   if ADead then
  745.   begin
  746.     MainForm.PlaySound('Explosion', False);
  747.     FMode := 2;
  748.     FCounter := 0;
  749.     Inc(MainForm.FScore, 1000);
  750.     Image := MainForm.ImageList.Items.Find('Explosion');
  751.     Width := Image.Width;
  752.     Height := Image.Height;
  753.     AnimCount := Image.PatternCount;
  754.     AnimLooped := False;
  755.     AnimSpeed := DEFAULT_ANIMSPEED;
  756.     AnimPos := 0;
  757.   end else
  758.   begin
  759.     MainForm.PlaySound('Hit', False);
  760.     Inc(MainForm.FScore, 100);
  761.   end;
  762. end;
  763.  
  764. procedure TEnemyUFO2.DoMove(MoveCount: Integer);
  765. begin
  766.   inherited DoMove(MoveCount);
  767.   if FMode=0 then
  768.   begin
  769.     X := X - MoveCount*(300/1000);
  770.     Y := Y + Cos256(FCounter div 15)*2;
  771.     if X<-Width then Dead;
  772.     if FCounter-FOldTamaTime>=100 then
  773.     begin
  774.       Inc(FTamaCount);
  775.       with TEnemyTama.Create(Engine) do
  776.       begin
  777.         FPlayerSprite := Self;
  778.         X := Self.X;
  779.         Y := Self.Y+Self.Height div 2-Height div 2;
  780.         Z := 10;
  781.       end;
  782.       FOldTamaTime := FCounter;
  783.     end;
  784.   end else if FMode=2 then
  785.   begin
  786.     X := X - MoveCount*(300/1000);
  787.     if FCounter>200 then Dead;
  788.   end;
  789.   inc(FCounter, MoveCount);
  790. end;
  791.  
  792. procedure TEnemyUFO2.HitEnemy(ADead: Boolean);
  793. begin
  794.   if ADead then
  795.   begin
  796.     MainForm.PlaySound('Explosion', False);
  797.     FMode := 2;
  798.     FCounter := 0;
  799.     Inc(MainForm.FScore, 1000);
  800.     Image := MainForm.ImageList.Items.Find('Explosion');
  801.     Width := Image.Width;
  802.     Height := Image.Height;
  803.     AnimCount := Image.PatternCount;
  804.     AnimLooped := False;
  805.     AnimSpeed := DEFAULT_ANIMSPEED;
  806.     AnimPos := 0;
  807.   end else
  808.   begin
  809.     MainForm.PlaySound('Hit', False);
  810.     Inc(MainForm.FScore, 100);
  811.   end;
  812. end;
  813.  
  814. constructor TEnemyUFO2.Create(AParent: TSprite);
  815. begin
  816.   inherited Create(AParent);
  817.   Image := MainForm.ImageList.Items.Find('Enemy-disk2');
  818.   Width := Image.Width;
  819.   Height := Image.Height;
  820.   AnimCount := Image.PatternCount;
  821.   AnimLooped := True;
  822.   AnimSpeed := DEFAULT_ANIMSPEED;
  823.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  824. end;
  825.  
  826. procedure TEnemyUFO.DoMove(MoveCount: Integer);
  827. begin
  828.   inherited DoMove(MoveCount);
  829.   if FMode=0 then
  830.   begin
  831.     X := X - MoveCount*(300/1000);
  832.     Y := Y + Cos256(FCounter div 15)*2;
  833.     if X<-Width then Dead;
  834.   end else if FMode=2 then
  835.   begin
  836.     X := X - MoveCount*(300/1000);
  837.     if FCounter>200 then Dead;
  838.   end;
  839.   inc(FCounter, MoveCount);
  840. end;
  841.  
  842. constructor TEnemyAttacker.Create(AParent: TSprite);
  843. begin
  844.   inherited Create(AParent);
  845.   Image := MainForm.ImageList.Items.Find('Enemy-Attacker');
  846.   Width := Image.Width;
  847.   Height := Image.Height;
  848.   AnimCount := Image.PatternCount;
  849.   AnimLooped := True;
  850.   AnimSpeed := DEFAULT_ANIMSPEED;
  851.   PixelCheck := True;
  852.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  853. end;
  854.  
  855. procedure TEnemyAttacker.HitEnemy(ADead: Boolean);
  856. begin
  857.   if ADead then
  858.   begin
  859.     MainForm.PlaySound('Explosion', False);
  860.     FMode := 2;
  861.     FCounter := 0;
  862.     Inc(MainForm.FScore, 1000);
  863.     Image := MainForm.ImageList.Items.Find('Explosion');
  864.     Width := Image.Width;
  865.     Height := Image.Height;
  866.     AnimCount := Image.PatternCount;
  867.     AnimLooped := False;
  868.     AnimSpeed := DEFAULT_ANIMSPEED;
  869.     AnimPos := 0;
  870.   end else
  871.   begin
  872.     MainForm.PlaySound('Hit', False);
  873.     Inc(MainForm.FScore, 100);
  874.   end;
  875. end;
  876.  
  877. procedure TEnemyAttacker.DoMove(MoveCount: Integer);
  878. begin
  879.   inherited DoMove(MoveCount);
  880.   if FMode=0 then
  881.   begin
  882.     X := X - MoveCount*(300/1000)-FCounter div 128;
  883.     if X < -Width then Dead;
  884.   end else if FMode=2 then
  885.   begin
  886.     X := X - MoveCount*(300/1000);
  887.     if FCounter>200 then Dead;
  888.   end;
  889.   inc(FCounter, MoveCount);
  890. end;
  891.  
  892. constructor TEnemyBoss.Create(AParent: TSprite);
  893. begin
  894.   inherited Create(AParent);
  895.   Image := MainForm.ImageList.Items.Find('Enemy-boss');
  896.   Width := Image.Width;
  897.   Height := Image.Height;
  898.   BossExists := true;
  899.   MainForm.PlayMusic(mtBoss);
  900.   AnimCount := Image.PatternCount;
  901.   AnimLooped := True;
  902.   AnimSpeed := DEFAULT_ANIMSPEED;
  903.   PixelCheck := True;
  904.   Collisioned := False;
  905.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  906.   MainForm.FBossLife := FLife;
  907.   waiter1 := 0;
  908.   waiter2 := 0;
  909. end;
  910.  
  911. procedure TEnemyBoss.HitEnemy(ADead: Boolean);
  912. begin
  913.   if ADead then
  914.   begin
  915.     MainForm.PlaySound('Explosion', False);
  916.     FMode := 2;
  917.     FCounter := 0;
  918.     Inc(MainForm.FScore, 100000);
  919.     BossExists := false;
  920.     dec(MainForm.FBossLife);
  921.   end else
  922.   begin
  923.     MainForm.PlaySound('Hit', False);
  924.     Inc(MainForm.FScore, 100);
  925.     dec(MainForm.FBossLife);
  926.   end;
  927. end;
  928.  
  929. procedure TEnemyBoss.DoMove(MoveCount: Integer);
  930. begin
  931.   inherited DoMove(MoveCount);
  932.   if FMode=0 then
  933.   begin
  934.     if X>((mainform.dxdraw.width/4) + (mainform.dxdraw.width/2) - (width/4)){450} then
  935.       X := X - MoveCount*(300/1000)
  936.     else
  937.     begin
  938.       Collisioned := True;
  939.       FMode := 1;
  940.       FPutTama := True;
  941.     end;
  942.     Y := Y + Cos256(FCounter div 15)*5;
  943.   end else if FMode=1 then
  944.   begin
  945.     Y := Y + Cos256(FCounter div 15)*5;
  946.     if FPutTama then
  947.     begin
  948.       if FTamaT>100 then
  949.       begin
  950.         with TEnemyTama.Create(Engine) do
  951.         begin
  952.           FPlayerSprite := Self;
  953.           Z := 1;
  954.           X := Self.X-Width;
  955.           Y := Self.Y+Self.Height div 2-Height div 2;
  956.         end;
  957.         Inc(FTamaF);
  958.         if FTamaF>Random(30) then FPutTama := False;
  959.         FTamaT := 0;
  960.       end;
  961.       FTamaT := FTamaT + MoveCount;
  962.     end else
  963.     begin
  964.       FTamaT := FTamaT + MoveCount;
  965.       if FTamaT>2000+Random(500) then
  966.       begin
  967.         FPutTama := True;
  968.         FTamaF := 0;
  969.         FTamaT := 0;
  970.       end;
  971.     end;
  972.   end else if FMode=2 then
  973.   begin
  974.     inc(waiter1);
  975.     if waiter1 = 3 then
  976.     begin
  977.       waiter1 := 0;
  978.       inc(waiter2);
  979.       if waiter2 <= 20 then
  980.       begin
  981.         with TExplosion.Create(Engine) do
  982.         begin
  983.           Z := 10;
  984.           X := Self.X+Random(Self.Width)-16;
  985.           Y := Self.Y+Random(Self.Height)-16;
  986.         end;
  987.       end
  988.       else
  989.       begin
  990.         Inc(MainForm.FScore, 1000);
  991.         FMode := 3;
  992.       end;
  993.     end;
  994.   end else if FMode=3 then
  995.   begin
  996.     if FCounter>4000 then dead;
  997.   end;
  998.   inc(FCounter, MoveCount);
  999. end;
  1000.  
  1001. constructor TEnemyAttacker2.Create(AParent: TSprite);
  1002. begin
  1003.   inherited Create(AParent);
  1004.   Image := MainForm.ImageList.Items.Find('Enemy-Attacker2');
  1005.   Width := Image.Width;
  1006.   Height := Image.Height;
  1007.   AnimCount := Image.PatternCount;
  1008.   AnimLooped := True;
  1009.   AnimSpeed := DEFAULT_ANIMSPEED;
  1010.   PixelCheck := True;
  1011.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  1012. end;
  1013.  
  1014. procedure TEnemyAttacker2.HitEnemy(ADead: Boolean);
  1015. begin
  1016.   if ADead then
  1017.   begin
  1018.     MainForm.PlaySound('Explosion', False);
  1019.     FMode := 2;
  1020.     FCounter := 0;
  1021.     Inc(MainForm.FScore, 5000);
  1022.     Image := MainForm.ImageList.Items.Find('Explosion');
  1023.     Width := Image.Width;
  1024.     Height := Image.Height;
  1025.     AnimCount := Image.PatternCount;
  1026.     AnimLooped := False;
  1027.     AnimSpeed := DEFAULT_ANIMSPEED;
  1028.     AnimPos := 0;
  1029.   end else
  1030.   begin
  1031.     MainForm.PlaySound('Hit', False);
  1032.     Inc(MainForm.FScore, 100);
  1033.   end;
  1034. end;
  1035.  
  1036. procedure TEnemyAttacker2.DoMove(MoveCount: Integer);
  1037. begin
  1038.   inherited DoMove(MoveCount);
  1039.   if FMode=0 then
  1040.   begin
  1041.     if X>((mainform.dxdraw.width/4) + (mainform.dxdraw.width/2) - (width/2)){450} then
  1042.       X := X - MoveCount*(300/1000)
  1043.     else
  1044.     begin
  1045.       Collisioned := True;
  1046.       FMode := 1;
  1047.       FPutTama := True;
  1048.     end;
  1049.     Y := Y + Cos256(FCounter div 15)*5;
  1050.   end else if FMode=1 then
  1051.   begin
  1052.     Y := Y + Cos256(FCounter div 15)*5;
  1053.     if FPutTama then
  1054.     begin
  1055.       if FTamaT>100 then
  1056.       begin
  1057.         with TEnemyTama.Create(Engine) do
  1058.         begin
  1059.           FPlayerSprite := Self;
  1060.           Z := 1;
  1061.           X := Self.X-Width;
  1062.           Y := Self.Y+Self.Height div 2-Height div 2;
  1063.         end;
  1064.         Inc(FTamaF);
  1065.         if FTamaF>Random(30) then FPutTama := False;
  1066.         FTamaT := 0;
  1067.       end;
  1068.       FTamaT := FTamaT + MoveCount;
  1069.     end else
  1070.     begin
  1071.       FTamaT := FTamaT + MoveCount;
  1072.       if FTamaT>2000+Random(500) then
  1073.       begin
  1074.         FPutTama := True;
  1075.         FTamaF := 0;
  1076.         FTamaT := 0;
  1077.       end;
  1078.     end;
  1079.   end else if FMode=2 then
  1080.   begin
  1081.     if FCounter>200 then Dead;
  1082.   end;
  1083.   inc(FCounter, MoveCount);
  1084. end;
  1085.  
  1086. procedure TEnemyAttacker3.HitEnemy(ADead: Boolean);
  1087. begin
  1088.   if ADead then
  1089.   begin
  1090.     MainForm.PlaySound('Explosion', False);
  1091.     FMode := 1;
  1092.     FCounter := 0;
  1093.     Inc(MainForm.FScore, 5000);
  1094.     Image := MainForm.ImageList.Items.Find('Explosion');
  1095.     Width := Image.Width;
  1096.     Height := Image.Height;
  1097.     AnimCount := Image.PatternCount;
  1098.     AnimLooped := False;
  1099.     AnimSpeed := DEFAULT_ANIMSPEED;
  1100.     AnimPos := 0;
  1101.   end else
  1102.   begin
  1103.     MainForm.PlaySound('Hit', False);
  1104.     Inc(MainForm.FScore, 100);
  1105.   end;
  1106. end;
  1107.  
  1108. procedure TEnemyAttacker3.DoMove(MoveCount: Integer);
  1109. begin
  1110.   inherited DoMove(MoveCount);
  1111.   if FMode=0 then
  1112.   begin
  1113.     X := X - (250/1000)*MoveCount;
  1114.     if X<-Width then Dead;
  1115.     if FCounter-FOldTamaTime>=100 then
  1116.     begin
  1117.       Inc(FTamaCount);
  1118.       with TEnemyTama.Create(Engine) do
  1119.       begin
  1120.         FPlayerSprite := Self;
  1121.         X := Self.X;
  1122.         Y := Self.Y+Self.Height div 2-Height div 2;
  1123.         Z := 10;
  1124.       end;
  1125.       FOldTamaTime := FCounter;
  1126.      end;
  1127.   end else if FMode=1 then
  1128.   begin
  1129.     if FCounter>200 then Dead;
  1130.   end;
  1131.   inc(FCounter, MoveCount);
  1132. end;
  1133.  
  1134. constructor TEnemyAttacker3.Create(AParent: TSprite);
  1135. begin
  1136.   inherited Create(AParent);
  1137.   Image := MainForm.ImageList.Items.Find('Enemy-Attacker3');
  1138.   Width := Image.Width;
  1139.   Height := Image.Height;
  1140.   AnimCount := Image.PatternCount;
  1141.   AnimLooped := True;
  1142.   AnimSpeed := DEFAULT_ANIMSPEED;
  1143.   PixelCheck := True;
  1144.   FLife := EnemyAdventTable[mainform.FEnemyAdventPos].lifes;
  1145. end;
  1146.  
  1147. function TMainForm.SoundKarte: boolean;
  1148. begin
  1149.   result := WaveOutGetNumDevs > 0;
  1150. end;
  1151.  
  1152. procedure TMainForm.FormCreate(Sender: TObject);
  1153. var
  1154.   Ergebnis: string;
  1155.   daten: textfile;
  1156.   ok: boolean;
  1157. begin
  1158.   { Beginne VCL-Ersatz }
  1159.   dxtimer := tdxtimer.Create(self);
  1160.   dxtimer.Interval := 33;
  1161.   dxtimer.OnActivate := DXTimerActivate;
  1162.   dxtimer.OnDeactivate := DXTimerDeactivate;
  1163.   dxtimer.OnTimer := DXTimerTimer;
  1164.   dxtimer.ActiveOnly := false;
  1165.   dxtimer.Enabled := false;
  1166.  
  1167.   dxdraw := tdxdraw.Create(self);
  1168.   dxdraw.Parent := self;
  1169.   dxdraw.Align := alClient;
  1170.   dxdraw.Left := 0;
  1171.   dxdraw.Top := 0;
  1172.   dxdraw.Width := 640;
  1173.   dxdraw.Height := 480;
  1174.   dxdraw.AutoInitialize := False;
  1175.   dxdraw.AutoSize := False;
  1176.   dxdraw.Color := clBlack;
  1177.   dxdraw.Display.BitCount := 24;
  1178.   dxdraw.Display.FixedBitCount := False;
  1179.   dxdraw.Display.FixedRatio := False;
  1180.   dxdraw.Display.FixedSize := False;
  1181.   dxdraw.Display.Height := 600;
  1182.   dxdraw.Display.Width := 800;
  1183.   dxdraw.Options := [doAllowReboot, doWaitVBlank, doAllowPalette256, doCenter, {doRetainedMode,} doHardware, doSelectDriver];
  1184.   dxdraw.TabOrder := 0;
  1185.   dxdraw.Visible := true;
  1186.   dxdraw.OnFinalize := DXDrawFinalize;
  1187.   dxdraw.OnInitialize := DXDrawInitialize;
  1188.   dxdraw.OnInitializing := DXDrawInitializing;
  1189.  
  1190.   dxsound := tdxsound.Create(self);
  1191.   dxsound.AutoInitialize := false;
  1192.  
  1193.   dxinput := tdxinput.Create(self);
  1194.   dxinput.Joystick.ForceFeedback := true;
  1195.   dxinput.Keyboard.ForceFeedback := true;
  1196.  
  1197.   wavelist := tdxwavelist.Create(self);
  1198.   wavelist.DXSound := dxsound;
  1199.  
  1200.   imagelist := tdximagelist.create(self);
  1201.   imagelist.DXDraw := dxdraw;
  1202.  
  1203.   spriteengine := tdxspriteengine.create(self);
  1204.   spriteengine.DXDraw := dxdraw;
  1205.  
  1206.   { Ende VCL-Ersatz }
  1207.  
  1208.   Application.Title := 'SpaceMission '+ProgramVersion;
  1209.   LoadOptions;
  1210.   DXInit;
  1211.   SoundInit;
  1212.   MusicInit;
  1213.   DeleteArray;
  1214.   if (paramcount = 0) and (fileexists(paramstr(1))) then // (paramcount > 0)
  1215.   begin
  1216.     AssignFile(daten, paramstr(1));
  1217.     Reset(daten);
  1218.     ok := true;
  1219.     ReadLN(daten, Ergebnis);
  1220.     if Ergebnis <> '; SpaceMission '+ProgramVersion then ok := false;
  1221.     ReadLN(daten, Ergebnis);
  1222.     if ergebnis <> '; SAV-File' then ok := false;
  1223.     if not ok then
  1224.     begin
  1225.       showmessage(FileError);
  1226.       CloseFile(daten);
  1227.       GameStartClick(GameStart);
  1228.       exit;
  1229.     end;
  1230.     ReadLN(daten, mainform.FScore);
  1231.     ReadLN(daten, mainform.FLife);
  1232.     ReadLN(daten, mainform.Flevel);
  1233.     ReadLN(daten, mainform.FMenuItem);
  1234.     CloseFile(daten);
  1235.     mainform.FNextScene := gsNewLevel;
  1236.     exit;
  1237.   end;
  1238.   GameStartClick(GameStart);
  1239. end;
  1240.  
  1241. procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
  1242.   Shift: TShiftState);
  1243. begin
  1244.   if (ssAlt in Shift) and (Key=VK_RETURN) then
  1245.     OptionFullScreenClick(OptionFullScreen);
  1246. end;
  1247.  
  1248. procedure TMainForm.GameStartClick(Sender: TObject);
  1249. begin
  1250.   StartScene(gsTitle);
  1251. end;
  1252.  
  1253. procedure TMainForm.GamePauseClick(Sender: TObject);
  1254. begin
  1255.   GamePause.Checked := not GamePause.Checked;
  1256.   DXTimer.Enabled := not GamePause.Checked;
  1257.   if GamePause.Checked then PauseMusic(FMusic) else
  1258.     ResumeMusic(FMusic);
  1259. end;
  1260.  
  1261. // http://www.delphipraxis.net/post43515.html
  1262. Function GetHTML(AUrl: string): string;
  1263. var
  1264.   databuffer : array[0..4095] of char;
  1265.   ResStr : string;
  1266.   hSession, hfile: hInternet;
  1267.   dwindex,dwcodelen,dwread,dwNumber: cardinal;
  1268.   dwcode : array[1..20] of char;
  1269.   res    : pchar;
  1270.   Str    : pchar;
  1271. begin
  1272.   ResStr:='';
  1273.   if system.pos('http://',lowercase(AUrl))=0 then
  1274.      AUrl:='http://'+AUrl;
  1275.  
  1276.   // Hinzugefügt
  1277.   application.ProcessMessages;
  1278.  
  1279.   hSession:=InternetOpen('InetURL:/1.0',
  1280.                          INTERNET_OPEN_TYPE_PRECONFIG,
  1281.                          nil,
  1282.                          nil,
  1283.                          0);
  1284.   if assigned(hsession) then
  1285.   begin
  1286.     // Hinzugefügt
  1287.     application.ProcessMessages;
  1288.  
  1289.     hfile:=InternetOpenUrl(
  1290.            hsession,
  1291.            pchar(AUrl),
  1292.            nil,
  1293.            0,
  1294.            INTERNET_FLAG_RELOAD,
  1295.            0);
  1296.     dwIndex  := 0;
  1297.     dwCodeLen := 10;
  1298.  
  1299.     // Hinzugefügt
  1300.     application.ProcessMessages;
  1301.  
  1302.     HttpQueryInfo(hfile,
  1303.                   HTTP_QUERY_STATUS_CODE,
  1304.                   @dwcode,
  1305.                   dwcodeLen,
  1306.                   dwIndex);
  1307.     res := pchar(@dwcode);
  1308.     dwNumber := sizeof(databuffer)-1;
  1309.     if (res ='200') or (res ='302') then
  1310.     begin
  1311.       while (InternetReadfile(hfile,
  1312.                               @databuffer,
  1313.                               dwNumber,
  1314.                               DwRead)) do
  1315.       begin
  1316.  
  1317.         // Hinzugefügt
  1318.         application.ProcessMessages;
  1319.  
  1320.         if dwRead =0 then
  1321.           break;
  1322.         databuffer[dwread]:=#0;
  1323.         Str := pchar(@databuffer);
  1324.         resStr := resStr + Str;
  1325.       end;
  1326.     end
  1327.     else
  1328.       ResStr := 'Status:'+res;
  1329.     if assigned(hfile) then
  1330.       InternetCloseHandle(hfile);
  1331.   end;
  1332.  
  1333.   // Hinzugefügt
  1334.   application.ProcessMessages;
  1335.  
  1336.   InternetCloseHandle(hsession);
  1337.   Result := resStr;
  1338. end;
  1339.  
  1340. procedure TMainForm.CheckUpdatesClick(Sender: TObject);
  1341. var
  1342.   temp: string;
  1343. begin
  1344.   temp := GetHTML('http://www.viathinksoft.de/update/?id=spacemission');
  1345.   if copy(temp, 0, 7) = 'Status:' then
  1346.   begin
  1347.     Application.MessageBox('Ein Fehler ist aufgetreten. Wahrscheinlich ist keine Internetverbindung aufgebaut, oder der der ViaThinkSoft-Server temporär offline.', 'Fehler', MB_OK + MB_ICONERROR)
  1348.   end
  1349.   else
  1350.   begin
  1351.     if GetHTML('http://www.viathinksoft.de/update/?id=spacemission') <> ProgramVersion then
  1352.     begin
  1353.       if Application.MessageBox('Eine neue Programmversion ist vorhanden. Möchten Sie diese jetzt herunterladen?', 'Information', MB_YESNO + MB_ICONASTERISK) = ID_YES then
  1354.         shellexecute(application.handle, 'open', pchar('http://www.viathinksoft.de/update/?id=@spacemission'), '', '', sw_normal);
  1355.     end
  1356.     else
  1357.     begin
  1358.       Application.MessageBox('Es ist keine neue Programmversion vorhanden.', 'Information', MB_OK + MB_ICONASTERISK);
  1359.     end;
  1360.   end;
  1361. end;
  1362.  
  1363. procedure TMainForm.BeendenClick(Sender: TObject);
  1364. begin
  1365.   close;
  1366. end;
  1367.  
  1368. procedure TMainForm.OptionFullScreenClick(Sender: TObject);
  1369. begin
  1370.   OptionFullScreen.Checked := not OptionFullScreen.Checked;
  1371.   DXInit;
  1372.   writeoptions;
  1373. end;
  1374.  
  1375. procedure TMainForm.OptionSoundClick(Sender: TObject);
  1376. begin
  1377.   OptionSound.Checked := not OptionSound.Checked;
  1378.   SoundInit;
  1379.   WriteOptions;
  1380. end;
  1381.  
  1382. procedure TMainForm.SoundInit;
  1383. begin
  1384.   if OptionSound.Checked then
  1385.   begin
  1386.     if not DXSound.Initialized then
  1387.     begin
  1388.       try
  1389.         DXSound.Initialize;
  1390.         WaveList.Items.LoadFromFile(FDirectory+'DirectX\Sound.dxw');
  1391.       except
  1392.         OptionSound.enabled := False;
  1393.         WaveList.items.clear;
  1394.       end;
  1395.     end;
  1396.   end
  1397.   else DXSound.Finalize;
  1398. end;
  1399.  
  1400. procedure TMainForm.MusicInit;
  1401. begin
  1402.   optionmusic.enabled := SoundKarte;
  1403. end;
  1404.  
  1405. procedure TMainForm.DestroyMusic(Name: TMusicTrack);
  1406. begin
  1407.   if Name = mtBoss then
  1408.   begin
  1409.     MCISendString(pchar('stop "'+FDirectory+'Musik\Boss.mid"'), nil, 255, 0);
  1410.     MCISendString(pchar('close "'+FDirectory+'Musik\Boss.mid"'), nil, 255, 0);
  1411.   end;
  1412.   if Name = mtGame then
  1413.   begin
  1414.     MCISendString(pchar('stop "'+FDirectory+'Musik\Game.mid"'), nil, 255, 0);
  1415.     MCISendString(pchar('close "'+FDirectory+'Musik\Game.mid"'), nil, 255, 0);
  1416.   end;
  1417.   if Name = mtScene then
  1418.   begin
  1419.     MCISendString(pchar('stop "'+FDirectory+'Musik\Scene.mid"'), nil, 255, 0);
  1420.     MCISendString(pchar('close "'+FDirectory+'Musik\Scene.mid"'), nil, 255, 0);
  1421.   end;
  1422.   if Name = mtTitle then
  1423.   begin
  1424.     MCISendString(pchar('stop "'+FDirectory+'Musik\Title.mid"'), nil, 255, 0);
  1425.     MCISendString(pchar('close "'+FDirectory+'Musik\Title.mid"'), nil, 255, 0);
  1426.   end;
  1427. end;
  1428.  
  1429. procedure TMainForm.OpenMusic(Name: TMusicTrack);
  1430. begin
  1431.   if Name = mtBoss then
  1432.     MCISendString(pchar('open "'+FDirectory+'Musik\Boss.mid"'), nil, 255, 0);
  1433.   if Name = mtGame then
  1434.     MCISendString(pchar('open "'+FDirectory+'Musik\Game.mid"'), nil, 255, 0);
  1435.   if Name = mtScene then
  1436.     MCISendString(pchar('open "'+FDirectory+'Musik\Scene.mid"'), nil, 255, 0);
  1437.   if Name = mtTitle then
  1438.     MCISendString(pchar('open "'+FDirectory+'Musik\Title.mid"'), nil, 255, 0);
  1439. end;
  1440.  
  1441. procedure TMainForm.PauseMusic(Name: TMusicTrack);
  1442. begin
  1443.   if not OptionMusic.checked then exit;
  1444.   if Name = mtBoss then
  1445.     MCISendString(pchar('stop "'+FDirectory+'Musik\Boss.mid"'), nil, 255, 0);
  1446.   if Name = mtGame then
  1447.     MCISendString(pchar('stop "'+FDirectory+'Musik\Game.mid"'), nil, 255, 0);
  1448.   if Name = mtScene then
  1449.     MCISendString(pchar('stop "'+FDirectory+'Musik\Scene.mid"'), nil, 255, 0);
  1450.   if Name = mtTitle then
  1451.     MCISendString(pchar('stop "'+FDirectory+'Musik\Title.mid"'), nil, 255, 0);
  1452. end;
  1453.  
  1454. procedure TMainForm.DXDrawInitializing(Sender: TObject);
  1455. begin
  1456.   if doFullScreen in DXDraw.Options then
  1457.   begin
  1458.     BorderStyle := bsNone;
  1459.     DXDraw.Cursor := crNone;
  1460.   end else
  1461.   begin
  1462.     BorderStyle := bsSingle;
  1463.     DXDraw.Cursor := crDefault;
  1464.   end;
  1465. end;
  1466.  
  1467. procedure TMainForm.DXDrawInitialize(Sender: TObject);
  1468. begin
  1469.   DXTimer.Enabled := True;
  1470. end;
  1471.  
  1472. procedure TMainForm.DXDrawFinalize(Sender: TObject);
  1473. begin
  1474.   DXTimer.Enabled := False;
  1475. end;
  1476.  
  1477. procedure TMainForm.DXTimerActivate(Sender: TObject);
  1478. begin
  1479.   Caption := Application.Title;
  1480.   if not ProgrammGestartet then
  1481.   begin
  1482.     Programmgestartet := true;
  1483.     exit;
  1484.   end;
  1485.   ResumeMusic(FMusic);
  1486. end;
  1487.  
  1488. procedure TMainForm.DXTimerDeactivate(Sender: TObject);
  1489. begin
  1490.   Caption := Application.Title + ' [Pause]';
  1491.   PauseMusic(FMusic);
  1492. end;
  1493.  
  1494. function TMainForm.StatusMusic(Name: TMusicTrack): string;
  1495. var
  1496.   MCIStatus: array[0..255] of char;
  1497. begin
  1498.   if not OptionMusic.checked then exit;
  1499.   if FMusic = mtGame then
  1500.     MCISendString(pchar('status "'+FDirectory+'Musik\Game.mid" mode'), MCIStatus, 255, 0);
  1501.   if FMusic = mtBoss then
  1502.     MCISendString(pchar('status "'+FDirectory+'Musik\Boss.mid" mode'), MCIStatus, 255, 0);
  1503.   if FMusic = mtScene then
  1504.     MCISendString(pchar('status "'+FDirectory+'Musik\Scene.mid" mode'), MCIStatus, 255, 0);
  1505.   if FMusic = mtTitle then
  1506.     MCISendString(pchar('status "'+FDirectory+'Musik\Title.mid" mode'), MCIStatus, 255, 0);
  1507.   result := MCIStatus;
  1508. end;
  1509.  
  1510. procedure TMainForm.DXTimerTimer(Sender: TObject; LagCount: Integer);
  1511. begin
  1512.   if StatusMusic(FMusic) = 'stopped' then
  1513.     PlayMusic(FMusic); {...}
  1514.   if crash then
  1515.   begin
  1516.     inc(Crash2);
  1517.     if crash2=30 then
  1518.     begin
  1519.       Crash2 := 0;
  1520.       crash := false;
  1521.       crashsound := false;
  1522.     end;
  1523.   end;
  1524.   if not DXDraw.CanDraw then exit;
  1525.   DXInput.Update;
  1526.   case FScene of
  1527.     gsTitle   : SceneTitle;
  1528.     gsMain    : SceneMain;
  1529.     gsGameOver: SceneGameOver;
  1530.     gsWin     : SceneWin;
  1531.     gsNewLevel: SceneNewLevel;
  1532.   end;
  1533.   if FNextScene<>gsNone then
  1534.   begin
  1535.     StartScene(FNextScene);
  1536.     FNextScene := gsNone;
  1537.   end;
  1538.   DXDraw.Flip;
  1539. end;
  1540.  
  1541. procedure TMainForm.BlinkStart;
  1542. begin
  1543.   FBlink := 0;
  1544.   FBlinkTime := GetTickCount;
  1545. end;
  1546.  
  1547. procedure TMainForm.WriteOptions;
  1548. var
  1549.   INIDatei: TIniFile;
  1550. begin
  1551.   INIDatei := TIniFile.Create(FDirectory+'Einstellungen\SpaceMission.ini');
  1552.   if OptionMusic.checked then INIDatei.WriteBool('Settings', 'Music', true)
  1553.     else INIDatei.WriteBool('Settings', 'Music', false);
  1554.   if OptionSound.checked then INIDatei.WriteBool('Settings', 'Sound', true)
  1555.     else INIDatei.WriteBool('Settings', 'Sound', false);
  1556.   if OptionFullScreen.checked then INIDatei.WriteBool('Settings', 'FullScreen', true)
  1557.     else INIDatei.WriteBool('Settings', 'FullScreen', false);
  1558.   if OptionBreitbild.checked then INIDatei.WriteBool('Settings', 'ScreenAutoSize', true)
  1559.     else INIDatei.WriteBool('Settings', 'ScreenAutoSize', false);
  1560.   if FInterval = giLeicht then INIDatei.WriteInteger('Settings', 'Speed', 1);
  1561.   if FInterval = giMittel then INIDatei.WriteInteger('Settings', 'Speed', 2);
  1562.   if FInterval = giSchwer then INIDatei.WriteInteger('Settings', 'Speed', 3);
  1563.   if FInterval = giMaster then INIDatei.WriteInteger('Settings', 'Speed', 4);
  1564.   INIDatei.Free;
  1565. end;
  1566.  
  1567. procedure TMainForm.LoadOptions;
  1568. var
  1569.   INIDatei: TIniFile;
  1570. begin
  1571.   INIDatei := TIniFile.Create(FDirectory+'Einstellungen\SpaceMission.ini');
  1572.   optionmusic.checked := INIDatei.ReadBool('Settings', 'Music', true);
  1573.   optionsound.checked := INIDatei.ReadBool('Settings', 'Sound', true);
  1574.   optionfullscreen.checked := INIDatei.ReadBool('Settings', 'fullscreen', false);
  1575.   OptionBreitBild.checked := INIDatei.ReadBool('Settings', 'ScreenAutoSize', true);
  1576.   if INIDatei.ReadInteger('Settings', 'Speed', 2) = 1 then
  1577.   begin
  1578.     FInterval := giLeicht;
  1579.     Leicht.checked := true;
  1580.   end;
  1581.   if INIDatei.ReadInteger('Settings', 'Speed', 2) = 2 then
  1582.   begin
  1583.     FInterval := giMittel;
  1584.     Mittel.checked := true;
  1585.   end;
  1586.   if INIDatei.ReadInteger('Settings', 'Speed', 2) = 3 then
  1587.   begin
  1588.     FInterval := giSchwer;
  1589.     Schwer.checked := true;
  1590.   end;
  1591.   if INIDatei.ReadInteger('Settings', 'Speed', 2) = 4 then
  1592.   begin
  1593.     FInterval := giMaster;
  1594.     Master.checked := true;
  1595.   end;
  1596.   INIDatei.Free;
  1597.   WriteOptions;
  1598. end;
  1599.  
  1600. procedure TMainForm.BlinkUpdate;
  1601. begin
  1602.   if GetTickCount<>FBlinkTime then
  1603.   begin
  1604.     FBlink := FBlink + (GetTickCount-FBlinkTime);
  1605.     FBlinkTime := GetTickCount;
  1606.   end;
  1607. end;
  1608.  
  1609. procedure TMainForm.PlaySound(Name: string; Wait: Boolean);
  1610. begin
  1611.   if (OptionSound.Checked) and (OptionSound.Enabled) then
  1612.     WaveList.Items.Find(Name).Play(Wait);
  1613. end;
  1614.  
  1615. procedure TMainForm.PlayMusic(Name: TMusicTrack);
  1616. begin
  1617.   if (not mainform.active) and (mainform.visible) then //1st Programmstart
  1618.     exit;
  1619.   if (OptionMusic.checked) and (OptionMusic.enabled) then
  1620.   begin
  1621.     DestroyMusic(FMusic);
  1622.     OpenMusic(Name);
  1623.     ResumeMusic(Name);
  1624.   end;
  1625.   FMusic := Name;
  1626. end;
  1627.  
  1628. function TMainForm.ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
  1629. begin
  1630.   with Result do
  1631.   begin
  1632.     rgbRed := Src.rgbRed+((Dest.rgbRed-Src.rgbRed)*Percent div 256);
  1633.     rgbGreen := Src.rgbGreen+((Dest.rgbGreen-Src.rgbGreen)*Percent div 256);
  1634.     rgbBlue := Src.rgbBlue+((Dest.rgbBlue-Src.rgbBlue)*Percent div 256);
  1635.     rgbReserved := 0;
  1636.   end;
  1637. end;
  1638.  
  1639. procedure TMainForm.PalleteAnim(Col: TRGBQuad; Time: Integer);
  1640. var
  1641.   i: Integer;
  1642.   t, t2: DWORD;
  1643.   ChangePalette: Boolean;
  1644.   c: Integer;
  1645. begin
  1646.   if DXDraw.Initialized then
  1647.   begin
  1648.     c := DXDraw.Surface.ColorMatch(RGB(Col.rgbRed, Col.rgbGreen, Col.rgbBlue));
  1649.     ChangePalette := False;
  1650.     if DXDraw.CanPaletteAnimation then
  1651.     begin
  1652.       t := GetTickCount;
  1653.       while Abs(GetTickCount-t)<Time do
  1654.       begin
  1655.         t2 := Trunc(Abs(GetTickCount-t)/Time*255);
  1656.         for i := 0 to 255 do
  1657.           DXDraw.ColorTable[i] := ComposeColor(Col, DXDraw.DefColorTable[i], t2);
  1658.         DXDraw.UpdatePalette;
  1659.         ChangePalette := True;
  1660.       end;
  1661.     end else
  1662.       Sleep(Time);
  1663.     for i := 0 to 4 do
  1664.     begin
  1665.       DXDraw.Surface.Fill(c);
  1666.       DXDraw.Flip;
  1667.     end;
  1668.     if ChangePalette then
  1669.     begin
  1670.       DXDraw.ColorTable := DXDraw.DefColorTable;
  1671.       DXDraw.UpdatePalette;
  1672.     end;
  1673.     DXDraw.Surface.Fill(c);
  1674.     DXDraw.Flip;
  1675.   end;
  1676. end;
  1677.  
  1678. procedure TMainForm.StartScene(Scene: TGameScene);
  1679. begin
  1680.   EndScene;
  1681.   DXInput.States := DXInput.States - DXInputButton;
  1682.   FScene := Scene;
  1683.   BlinkStart;
  1684.   case FScene of
  1685.     gsTitle   : StartSceneTitle;
  1686.     gsMain    : StartSceneMain;
  1687.     gsGameOver: StartSceneGameOver;
  1688.     gsWin     : StartSceneWin;
  1689.     gsNewLevel: StartSceneNewLevel;
  1690.   end;
  1691. end;
  1692.  
  1693. procedure TMainForm.StartSceneTitle;
  1694. begin
  1695.   sleep(500);
  1696.   FCheat := false;
  1697.   BossExists := false;
  1698.   FLife := Lives;
  1699.   FLevel := 0;
  1700.   FScore := 0;
  1701.   FNotSave := true;
  1702.   Cheat.enabled := false;
  1703.   Neustart.enabled := false;
  1704.   GamePause.enabled := false;
  1705.   GameStart.enabled := false;
  1706.   Spielgeschwindigkeit.enabled := false;
  1707.   mainform.Visible := true;
  1708.   PlayMusic(mtTitle);
  1709. end;
  1710.  
  1711. procedure TMainForm.StartSceneMain;
  1712. {var
  1713.   i, j: Integer;}
  1714. begin
  1715.   sleep(500);
  1716.   FCounter := 0;
  1717.   NewLevel(FLevel);
  1718.   BossExists := false;
  1719.   PlayMusic(mtGame);
  1720.   FEnemyAdventPos := 1;
  1721.   FFrame := -4;
  1722.   PlayerSprite := TPlayerSprite.Create(SpriteEngine.Engine);
  1723.   with TBackground.Create(SpriteEngine.Engine) do
  1724.   begin
  1725.     SetMapSize(1, 1);
  1726.     Image := mainform.ImageList.Items.Find('Star3');
  1727.     Z := -13;
  1728.     Y := 40;
  1729.     FSpeed := 1 / 2;
  1730.     Tile := True;
  1731.   end;
  1732.   with TBackground.Create(SpriteEngine.Engine) do
  1733.   begin
  1734.     SetMapSize(1, 1);
  1735.     Image := mainform.ImageList.Items.Find('Star2');
  1736.     Z := -12;
  1737.     Y := 30;
  1738.     FSpeed := 1;
  1739.     Tile := True;
  1740.   end;
  1741.   with TBackground.Create(SpriteEngine.Engine) do
  1742.   begin
  1743.     SetMapSize(1, 1);
  1744.     Image := mainform.ImageList.Items.Find('Star1');
  1745.     Z := -11;
  1746.     Y := 10;
  1747.     FSpeed := 2;
  1748.     Tile := True;
  1749.   end;
  1750.   {with TBackground.Create(SpriteEngine.Engine) do
  1751.   begin
  1752.     SetMapSize(200, 10);
  1753.     Y := 10;
  1754.     Z := -13;
  1755.     FSpeed := 1 / 2;
  1756.     Tile := True;
  1757.     for i := 0 to MapHeight-1 do
  1758.     begin
  1759.       for j := 0 to MapWidth-1 do
  1760.       begin
  1761.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 8);
  1762.         if Random(100)<95 then Chips[j, i] := -1;
  1763.       end;
  1764.     end;
  1765.   end;
  1766.   with TBackground.Create(SpriteEngine.Engine) do
  1767.   begin
  1768.     SetMapSize(200, 10);
  1769.     Y := 30;
  1770.     Z := -12;
  1771.     FSpeed := 1;
  1772.     Tile := True;
  1773.     for i := 0 to MapHeight-1 do
  1774.     begin
  1775.       for j := 0 to MapWidth-1 do
  1776.       begin
  1777.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 4);
  1778.         if Random(100)<95 then Chips[j, i] := -1;
  1779.       end;
  1780.     end;
  1781.   end;
  1782.   with TBackground.Create(SpriteEngine.Engine) do
  1783.   begin
  1784.     SetMapSize(200, 10);
  1785.     Y := 40;
  1786.     Z := -11;
  1787.     FSpeed := 2;
  1788.     Tile := True;
  1789.     for i := 0 to MapHeight-1 do
  1790.     begin
  1791.       for j := 0 to MapWidth-1 do
  1792.       begin
  1793.         Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 2);
  1794.         if Random(100)<95 then Chips[j, i] := -1;
  1795.       end;
  1796.     end;
  1797.   end;}
  1798.   FNotSave := false;
  1799.   Cheat.enabled := true;
  1800.   Neustart.enabled := true;
  1801.   GamePause.enabled := true;
  1802.   GameStart.enabled := true;
  1803.   Spielgeschwindigkeit.enabled := true;
  1804. end;
  1805.  
  1806. procedure TMainForm.StartSceneGameOver;
  1807. begin
  1808.   sleep(500);
  1809.   FNotSave := true;
  1810.   Cheat.enabled := false;
  1811.   Spielgeschwindigkeit.enabled := false;
  1812.   Neustart.enabled := false;
  1813.   GamePause.enabled := false;
  1814.   PlayMusic(mtScene);
  1815.   BossExists := false;
  1816. end;
  1817.  
  1818. procedure TMainForm.StartSceneWin;
  1819. begin
  1820.   sleep(500);
  1821.   FNotSave := true;
  1822.   Cheat.enabled := false;
  1823.   Spielgeschwindigkeit.enabled := false;
  1824.   Neustart.enabled := false;
  1825.   GamePause.enabled := false;
  1826.   PlayMusic(mtScene);
  1827.   BossExists := false;
  1828. end;
  1829.  
  1830. procedure TMainForm.EndScene;
  1831. begin
  1832.   case FScene of
  1833.     gsTitle   : EndSceneTitle;
  1834.     gsMain    : EndSceneMain;
  1835.     gsGameOver: EndSceneGameOver;
  1836.     gsWin     : EndSceneWin;
  1837.     gsNewLevel: EndSceneNewLevel;
  1838.   end;
  1839. end;
  1840.  
  1841. procedure TMainForm.EndSceneTitle;
  1842. begin
  1843.   {  Ende Title  }
  1844. end;
  1845.  
  1846. procedure TMainForm.EndSceneMain;
  1847. begin
  1848.   SpriteEngine.Engine.Clear;
  1849. end;
  1850.  
  1851. procedure TMainForm.EndSceneGameOver;
  1852. begin
  1853.   {  Ende GameOver  }
  1854. end;
  1855.  
  1856. procedure TMainForm.EndSceneWin;
  1857. begin
  1858.   {  Ende Win  }
  1859. end;
  1860.  
  1861. procedure TMainForm.DeleteArray();
  1862. var
  1863.   i: integer;
  1864. begin
  1865.   for i := Low(EnemyAdventTable) to High(EnemyAdventTable) do
  1866.   begin
  1867.     EnemyAdventTable[i].spriteClass := TNothing;
  1868.     EnemyAdventTable[i].x := 0;
  1869.     EnemyAdventTable[i].y := 0;
  1870.     EnemyAdventTable[i].lifes := 0;
  1871.   end;
  1872.   FRestEnemys := 0;
  1873. end;
  1874.  
  1875. procedure TMainForm.NewLevel(lev: integer);
  1876. resourcestring
  1877.   LNG_LEVEL_INVALID = 'Das Level Nr. %d ist ungültig!'+#13#10+'Das Programm wird beendet.';
  1878. var
  1879.   act: integer;
  1880.   filex: textfile;
  1881.   ergebniss: string;
  1882. begin
  1883.   DeleteArray;
  1884.   if FMenuItem = 2 then
  1885.   begin
  1886.     enemys[1] := TEnemyAttacker;
  1887.     enemys[2] := TEnemyMeteor;
  1888.     enemys[3] := TEnemyUFO;
  1889.     enemys[4] := TEnemyAttacker;
  1890.     enemys[5] := TEnemyMeteor;
  1891.     enemys[6] := TEnemyUFO;
  1892.     enemys[7] := TEnemyAttacker;
  1893.     enemys[8] := TEnemyMeteor;
  1894.     enemys[9] := TEnemyUFO;
  1895.     enemys[10] := TEnemyAttacker;
  1896.     enemys[11] := TEnemyMeteor;
  1897.     enemys[12] := TEnemyUFO;
  1898.     enemys[13] := TEnemyAttacker;
  1899.     enemys[14] := TEnemyMeteor;
  1900.     enemys[15] := TEnemyUFO;
  1901.     enemys[16] := TEnemyAttacker3;
  1902.     enemys[17] := TEnemyAttacker;
  1903.     enemys[18] := TEnemyMeteor;
  1904.     enemys[19] := TEnemyUFO;
  1905.     enemys[20] := TEnemyUFO2;
  1906.     enemys[21] := TEnemyAttacker;
  1907.     enemys[22] := TEnemyMeteor;
  1908.     enemys[23] := TEnemyUFO;
  1909.     enemys[24] := TEnemyAttacker2;
  1910.     enemys[25] := TEnemyMeteor;
  1911.     enemys[26] := TEnemyUFO;
  1912.     enemys[27] := TEnemyAttacker;
  1913.     randomize;
  1914.     for act := 1 to lev*75-1 do
  1915.     begin
  1916.       inc(FRestEnemys);
  1917.       EnemyAdventTable[act].spriteClass := enemys[random(lev+2)+1];
  1918.       if EnemyAdventTable[act].spriteClass = TEnemyAttacker2 then EnemyAdventTable[act].spriteClass := enemys[random(lev+2)+1]; {O_o}
  1919.       EnemyAdventTable[act].x := act*30 + random(85-(lev+(random(lev))*2)){O_o};
  1920.       EnemyAdventTable[act].y := random(dxdraw.surfaceheight);
  1921.       if (EnemyAdventTable[act].spriteClass <> TEnemyMeteor) and (EnemyAdventTable[act].spriteClass <> TEnemyAttacker2) then EnemyAdventTable[act].lifes := random(lev)+1;
  1922.       if EnemyAdventTable[act].spriteClass = TEnemyAttacker2 then EnemyAdventTable[act].lifes := random(6)+1{O_o};
  1923.     end;
  1924.     EnemyAdventTable[lev*75].spriteClass := TEnemyBoss;
  1925.     EnemyAdventTable[lev*75].x := lev*75*30{O_o} div lev;
  1926.     EnemyAdventTable[lev*75].y := (dxdraw.surfaceheight div 2) - (MainForm.ImageList.Items.Find('Enemy-boss').height div 2);
  1927.     EnemyAdventTable[lev*75].lifes := lev*5;
  1928.     inc(FRestEnemys);
  1929.   end
  1930.   else
  1931.   begin
  1932.     enemys[1] := TEnemyAttacker;
  1933.     enemys[2] := TEnemyAttacker2;
  1934.     enemys[3] := TEnemyAttacker3;
  1935.     enemys[4] := TEnemyMeteor;
  1936.     enemys[5] := TEnemyUFO;
  1937.     enemys[6] := TEnemyUFO2;
  1938.     enemys[7] := TEnemyBoss;
  1939.     if fileexists(FDirectory+'Levels\Level '+inttostr(lev)+'.lev') then
  1940.     begin
  1941.       levact := 0;
  1942.       assignfile(filex, FDirectory+'Levels\Level '+inttostr(lev)+'.lev');
  1943.       reset(filex);
  1944.       while not seekEoF(filex) do
  1945.       begin
  1946.         if levact = 0 then
  1947.         begin
  1948.           readln(filex, ergebniss);
  1949.           if ergebniss <> '; SpaceMission '+FCompVersion then
  1950.           begin
  1951.             showmessage(Format(LNG_LEVEL_INVALID, [lev]));
  1952.             application.terminate;
  1953.             exit;
  1954.           end;
  1955.           readln(filex, ergebniss);
  1956.           if ergebniss <> '; LEV-File' then
  1957.           begin
  1958.             showmessage(Format(LNG_LEVEL_INVALID, [lev]));
  1959.             application.terminate;
  1960.             exit;
  1961.           end;
  1962.           readln(filex);
  1963.         end;
  1964.         inc(levact);
  1965.         readln(filex, ergebniss);
  1966.         if levact = 5 then levact := 1;
  1967.         if levact = 1 then
  1968.         begin
  1969.           inc(pos[levact]);
  1970.           inc(FRestEnemys);
  1971.           EnemyAdventTable[pos[levact]].spriteClass := enemys[strtoint(ergebniss)];
  1972.         end;
  1973.         if levact = 2 then
  1974.         begin
  1975.           inc(pos[levact]);
  1976.           EnemyAdventTable[pos[levact]].x := strtoint(ergebniss);
  1977.         end;
  1978.         if levact = 3 then
  1979.         begin
  1980.           inc(pos[levact]);
  1981.           EnemyAdventTable[pos[levact]].y := strtoint(ergebniss);
  1982.         end;
  1983.         if levact = 4 then
  1984.         begin
  1985.           inc(pos[levact]);
  1986.           EnemyAdventTable[pos[levact]].lifes := strtoint(ergebniss);
  1987.         end;
  1988.       end;
  1989.       closefile(filex);
  1990.     end;
  1991.   end;
  1992. end;
  1993.  
  1994. procedure TMainForm.SceneTitle;
  1995. var
  1996.   Logo: TPictureCollectionItem;
  1997. begin
  1998.   DXDraw.Surface.Fill(0);
  1999.   Logo := ImageList.Items.Find('Logo');
  2000.   {Logo.DrawWaveX(DXDraw.Surface, (dxdraw.surfaceWidth div 2) - 181, 65, Logo.Width, Logo.Height, 0,
  2001.     Trunc(16 - Cos256(FBlink div 60) * 16), 32, -FBlink div 5);}
  2002.   Logo.DrawWaveX(DXDraw.Surface, trunc((dxdraw.surfaceWidth / 2) - (Logo.Width / 2)), 65, Logo.Width, Logo.Height, 0,
  2003.     2, 80, Fangle * 4);
  2004.   inc(Fangle);
  2005.   with DXDraw.Surface.Canvas do
  2006.   begin
  2007.     if (isDown in MainForm.DXInput.States) and (FMenuItem=1) then FMenuItem := 2;
  2008.     if ((isUp in MainForm.DXInput.States) and (FMenuItem=2)) or (FMenuItem=0) then FMenuItem := 1;
  2009.     Brush.Style := bsClear;
  2010.     Font.Size := 30;
  2011.     if FMenuItem = 1 then
  2012.     begin
  2013.       Font.Color := clMaroon;
  2014.       Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-52, 'Normales Spiel');
  2015.       Textout((dxdraw.surfaceWidth div 2)-187, (dxdraw.surfaceheight div 2)-52, '>');
  2016.       Font.Color := clRed;
  2017.       Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)-50, 'Normales Spiel');
  2018.       Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)-50, '>');
  2019.       Font.Color := clOlive;
  2020.       Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-2, 'Zufallslevel');
  2021.       Font.Color := clYellow;
  2022.       Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2), 'Zufallslevel');
  2023.     end
  2024.     else
  2025.     begin
  2026.       Font.Color := clOlive;
  2027.       Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-52, 'Normales Spiel');
  2028.       Font.Color := clYellow;
  2029.       Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)-50, 'Normales Spiel');
  2030.       Font.Color := clMaroon;
  2031.       Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-2, 'Zufallslevel');
  2032.       Textout((dxdraw.surfaceWidth div 2)-187, (dxdraw.surfaceheight div 2)-2, '>');
  2033.       Font.Color := clRed;
  2034.       Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2), 'Zufallslevel');
  2035.       Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2), '>');
  2036.     end;
  2037.     { if (FBlink div 300) mod 2=0 then
  2038.     begin
  2039.       Font.Color := clGreen;
  2040.       Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste');
  2041.       Font.Color := clLime;
  2042.       Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste');
  2043.     end; }
  2044.     BlinkUpdate;
  2045.     Release;
  2046.   end;
  2047.   // Weiter mit Leertaste oder Enter
  2048.   if (isButton1 in DXInput.States) or (isButton2 in DXInput.States) then
  2049.   begin
  2050.     FLevel := 1;
  2051.     if ((FMenuItem=1) and (fileexists(FDirectory+'Levels\Level '+inttostr(FLevel)+'.lev')=false)) or ((FMenuItem=2) and (FLevel > 20)) then
  2052.     begin
  2053.       //PlaySound('Frage', False);
  2054.       exit;
  2055.     end;
  2056.     NewLevel(FLevel);
  2057.     PlaySound('SceneMov', False);
  2058.     PalleteAnim(RGBQuad(0, 0, 0), 300);
  2059.     Sleep(200);
  2060.     StartScene(gsMain);
  2061.   end;
  2062. end;
  2063.  
  2064. procedure TMainForm.SceneMain;
  2065. var
  2066.   Enemy: TSprite;
  2067. begin
  2068.   if FInterval = giLeicht then SpriteEngine.Move(conleicht);
  2069.   if FInterval = giMittel then SpriteEngine.Move(conmittel);
  2070.   if FInterval = giSchwer then SpriteEngine.Move(conschwer);
  2071.   if FInterval = giMaster then SpriteEngine.Move(conmaster);
  2072.   SpriteEngine.Dead;
  2073.   while (Low(EnemyAdventTable)<=FEnemyAdventPos) and
  2074.     (FEnemyAdventPos<=High(EnemyAdventTable)) and
  2075.     ((EnemyAdventTable[FEnemyAdventPos].x / 4)<=FFrame) and
  2076.     (FRestEnemys>0) do
  2077.   begin
  2078.     if EnemyAdventTable[FEnemyAdventPos].spriteClass <> TNothing then
  2079.     begin
  2080.       with EnemyAdventTable[FEnemyAdventPos] do
  2081.       begin
  2082.         Enemy := spriteClass.Create(SpriteEngine.Engine);
  2083.         Enemy.x := dxdraw.surfacewidth;
  2084.         //Enemy.y := y;
  2085.         if y <> 0 then Enemy.y := dxdraw.surfaceheight / (480{maximale Bandbreite im alten Format} / y)
  2086.           else Enemy.y := 0;
  2087.       end;
  2088.     end;
  2089.     Inc(FEnemyAdventPos);
  2090.   end;
  2091.   Inc(FFrame);
  2092.   DXDraw.Surface.Fill(0);
  2093.   if FNextScene=gsNone then
  2094.   begin
  2095.     SpriteEngine.Draw;
  2096.     if MainForm.flife > 0 then
  2097.     begin
  2098.       with DXDraw.Surface.Canvas do
  2099.       begin
  2100.         Brush.Style := bsClear;
  2101.         Font.Size := 20;
  2102.         Font.Color := clOlive;
  2103.         Textout(9, 9, 'Punkte: ' + FloatToStrF(FScore,ffNumber,14,0));
  2104.         Font.Color := clYellow;
  2105.         Textout(10, 10, 'Punkte: ' + FloatToStrF(FScore,ffNumber,14,0));
  2106.         Font.Color := clMaroon;
  2107.         Textout(dxdraw.surfacewidth-141, 9, 'Level: ' + IntToStr(MainForm.flevel));
  2108.         Font.Color := clRed;
  2109.         Textout(dxdraw.surfacewidth-140, 10, 'Level: ' + IntToStr(MainForm.flevel));
  2110.         if FLife<0 then mainform.FLife := 0;
  2111.         if FCheat then
  2112.         begin
  2113.           Font.Color := clPurple;
  2114.           Textout(9, dxdraw.surfaceheight-41, 'Leben: ?');
  2115.           Font.Color := clFuchsia;
  2116.           Textout(10, dxdraw.surfaceheight-40, 'Leben: ?');
  2117.         end
  2118.         else
  2119.         begin
  2120.           if ((Flife = 1) and ((FBlink div 300) mod 2=0)) or (Flife <> 1) then
  2121.           begin
  2122.             Font.Color := clPurple;
  2123.             Textout(9, dxdraw.surfaceheight-41, 'Leben: ' + IntToStr(MainForm.flife));
  2124.             Font.Color := clFuchsia;
  2125.             Textout(10, dxdraw.surfaceheight-40, 'Leben: ' + IntToStr(MainForm.flife));
  2126.           end;
  2127.           if Flife = 1 then BlinkUpdate;
  2128.         end;
  2129.         {if BossExists and (FBossLife>0) then
  2130.         begin
  2131.           Font.Color := clPurple;
  2132.           Textout(449, 439, 'Boss: ' + IntToStr(FBossLife));
  2133.           Font.Color := clFuchsia;
  2134.           Textout(450, 440, 'Boss: ' + IntToStr(FBossLife));
  2135.         end
  2136.         else
  2137.           if RestlicheEinheiten>0 then
  2138.           begin
  2139.             Font.Color := clPurple;
  2140.             Textout(449, 439, 'Einheiten: ' + IntToStr(RestlicheEinheiten));
  2141.             Font.Color := clFuchsia;
  2142.             Textout(450, 440, 'Einheiten: ' + IntToStr(RestlicheEinheiten));
  2143.           end;}
  2144.         if BossExists and (FBossLife>0) then
  2145.         begin
  2146.           if (FRestEnemys>0) then
  2147.           begin
  2148.             Font.Color := clGreen;
  2149.             Textout(dxdraw.surfacewidth-191, dxdraw.surfaceheight-81, 'Boss: ' + IntToStr(FBossLife));
  2150.             Textout(dxdraw.surfacewidth-191, dxdraw.surfaceheight-41, 'Einheiten: ' + IntToStr(FRestEnemys));
  2151.             Font.Color := clLime;
  2152.             Textout(dxdraw.surfacewidth-190, dxdraw.surfaceheight-80, 'Boss: ' + IntToStr(FBossLife));
  2153.             Textout(dxdraw.surfacewidth-190, dxdraw.surfaceheight-40, 'Einheiten: ' + IntToStr(FRestEnemys));
  2154.           end;
  2155.           if (FRestEnemys<1) then
  2156.           begin
  2157.             Font.Color := clGreen;
  2158.             Textout(dxdraw.surfacewidth-191, dxdraw.surfaceheight-41, 'Boss: ' + IntToStr(FBossLife));
  2159.             Font.Color := clLime;
  2160.             Textout(dxdraw.surfacewidth-190, dxdraw.surfaceheight-40, 'Boss: ' + IntToStr(FBossLife));
  2161.           end;
  2162.         end;
  2163.         if (FRestEnemys>0) and not Bossexists then
  2164.         begin
  2165.           Font.Color := clGreen;
  2166.           Textout(dxdraw.surfacewidth-191, dxdraw.surfaceheight-41, 'Einheiten: ' + IntToStr(FRestEnemys));
  2167.           Font.Color := clLime;
  2168.           Textout(dxdraw.surfacewidth-190, dxdraw.surfaceheight-40, 'Einheiten: ' + IntToStr(FRestEnemys));
  2169.         end;
  2170.         Release;
  2171.       end;
  2172.     end
  2173.     else
  2174.     begin
  2175.       DXDraw.Surface.Canvas.Font.Color := clGreen; // Grüne schrift bei gescheitert? FIXME
  2176.       DXDraw.Surface.Canvas.Textout(dxdraw.surfacewidth-251, dxdraw.surfaceheight-41, 'Mission gescheitert!');
  2177.       DXDraw.Surface.Canvas.Font.Color := clLime;
  2178.       DXDraw.Surface.Canvas.Textout(dxdraw.surfacewidth-250, dxdraw.surfaceheight-40, 'Mission gescheitert!');
  2179.       DXDraw.Surface.Canvas.Release;
  2180.     end;
  2181.     if FRestEnemys<0 then FRestEnemys := 0; //Muss das sein?
  2182.     if (Ec=0) and (FRestEnemys=0){ and (SpielerFliegtFort = false)}
  2183.     and ((BossExists and (FBossLife=0)) or not BossExists) then
  2184.     begin
  2185.       DXDraw.Surface.Canvas.Font.Color := clGreen;
  2186.       DXDraw.Surface.Canvas.Textout(dxdraw.surfacewidth-251, dxdraw.surfaceheight-41, 'Mission erfolgreich!');
  2187.       DXDraw.Surface.Canvas.Font.Color := clLime;
  2188.       DXDraw.Surface.Canvas.Textout(dxdraw.surfacewidth-250, dxdraw.surfaceheight-40, 'Mission erfolgreich!');
  2189.       DXDraw.Surface.Canvas.Release;
  2190.       Sleep(1);
  2191.       inc(FCounter);
  2192.       if FCounter>150{200} then PlayerSprite.FlyAway;
  2193.     end;
  2194.   end;
  2195. end;
  2196.  
  2197. procedure TMainForm.SceneGameOver;
  2198. begin
  2199.   DXDraw.Surface.Fill(0);
  2200.   with DXDraw.Surface.Canvas do
  2201.   begin
  2202.     FNotSave := true;
  2203.     Cheat.enabled := false;
  2204.     GamePause.enabled := false;
  2205.     Neustart.enabled := false;
  2206.     Brush.Style := bsClear;
  2207.     Font.Size := 35;
  2208.     Font.Color := clMaroon;
  2209.     Textout((dxdraw.surfacewidth div 2)-127, 98, 'Verloren!');
  2210.     Font.Color := clRed;
  2211.     Textout((dxdraw.surfacewidth div 2)-125, 100, 'Verloren!');
  2212.     if (FBlink div 300) mod 2=0 then
  2213.     begin
  2214.       Font.Size := 30;
  2215.       Font.Color := clOlive;
  2216.       Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste');
  2217.       Font.Color := clYellow;
  2218.       Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste');
  2219.     end;
  2220.     BlinkUpdate;
  2221.     Release;
  2222.   end;
  2223.   if isButton1 in DXInput.States then
  2224.   begin
  2225.     PlaySound('SceneMov', False);
  2226.     PalleteAnim(RGBQuad(0, 0, 0), 300);
  2227.     Sleep(200);
  2228.     StartScene(gsTitle);
  2229.   end;
  2230. end;
  2231.  
  2232. procedure TMainForm.SceneWin;
  2233. begin
  2234.   DXDraw.Surface.Fill(0);
  2235.   with DXDraw.Surface.Canvas do
  2236.   begin
  2237.     FNotSave := true;
  2238.     Cheat.enabled := false;
  2239.     GamePause.enabled := false;
  2240.     Neustart.enabled := false;
  2241.     Brush.Style := bsClear;
  2242.     Font.Size := 35;
  2243.     Font.Color := clMaroon;
  2244.     Textout((dxdraw.surfaceWidth div 2)-127, 98, 'Gewonnen!');
  2245.     Font.Color := clRed;
  2246.     Textout((dxdraw.surfaceWidth div 2)-125, 100, 'Gewonnen!');
  2247.     if (FBlink div 300) mod 2=0 then
  2248.     begin
  2249.       Font.Size := 30;
  2250.       Font.Color := clOlive;
  2251.       Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste');
  2252.       Font.Color := clYellow;
  2253.       Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste');
  2254.     end;
  2255.     BlinkUpdate;
  2256.     Release;
  2257.   end;
  2258.   if isButton1 in DXInput.States then
  2259.   begin
  2260.     PlaySound('SceneMov', False);
  2261.     PalleteAnim(RGBQuad(0, 0, 0), 300);
  2262.     Sleep(200);
  2263.     StartScene(gsTitle);
  2264.   end;
  2265. end;
  2266.  
  2267. procedure TMainForm.StartSceneNewLevel;
  2268. begin
  2269.   sleep(500);
  2270.   FNotSave := false;
  2271.   Cheat.enabled := false;
  2272.   Neustart.enabled := false;
  2273.   GamePause.enabled := false;
  2274.   GameStart.enabled := true;
  2275.   Spielgeschwindigkeit.enabled := false;
  2276.   BossExists := false;
  2277.   Spielgeschwindigkeit.enabled := false;
  2278.   if ((FMenuItem=1) and (not fileexists(FDirectory+'Levels\Level '+inttostr(FLevel)+'.lev'))) or ((FMenuItem=2) and (FLevel > 25)) then
  2279.   begin
  2280.     //PlaySound('SceneMov', False);
  2281.     PalleteAnim(RGBQuad(0, 0, 0), 300);
  2282.     Sleep(200);
  2283.     StartScene(gsWin);
  2284.     exit;
  2285.   end;
  2286.   PlayMusic(mtScene);
  2287. end;
  2288.  
  2289. procedure TMainForm.EndSceneNewLevel;
  2290. begin
  2291.   {  Ende NewLevel  }
  2292. end;
  2293.  
  2294. procedure TMainForm.SceneNewLevel;
  2295. begin
  2296.   DXDraw.Surface.Fill(0);
  2297.   with DXDraw.Surface.Canvas do
  2298.   begin
  2299.     Brush.Style := bsClear;
  2300.     Font.Size := 40;
  2301.     Font.Color := clMaroon;
  2302.     Textout((dxdraw.surfaceWidth div 2)-(83+(length(inttostr(flevel))*22)), 98, 'Level '+inttostr(flevel));
  2303.     Font.Color := clRed;
  2304.     Textout((dxdraw.surfaceWidth div 2)-(81+(length(inttostr(flevel))*22)), 100, 'Level '+inttostr(flevel));
  2305.     if (FBlink div 300) mod 2=0 then
  2306.     begin
  2307.       Font.Size := 30;
  2308.       Font.Color := clOlive;
  2309.       Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste');
  2310.       Font.Color := clYellow;
  2311.       Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste');
  2312.     end;
  2313.     BlinkUpdate;
  2314.     Release;
  2315.   end;
  2316.   if isButton1 in DXInput.States then
  2317.   begin
  2318.     PlaySound('SceneMov', False);
  2319.     PalleteAnim(RGBQuad(0, 0, 0), 300);
  2320.     Sleep(200);
  2321.     StartScene(gsMain);
  2322.   end;
  2323. end;
  2324.  
  2325. procedure TMainForm.OptionMusicClick(Sender: TObject);
  2326. begin
  2327.   OptionMusic.Checked := not OptionMusic.Checked;
  2328.   if OptionMusic.Checked then
  2329.   begin
  2330.     PlayMusic(FMusic)
  2331.   end
  2332.   else
  2333.   begin
  2334.     DestroyMusic(FMusic);
  2335.   end;
  2336.   WriteOptions;
  2337. end;
  2338.  
  2339. procedure TMainForm.MasterClick(Sender: TObject);
  2340. begin
  2341.   master.checked := true;
  2342.   FInterval := giMaster;
  2343.   writeoptions;
  2344. end;
  2345.  
  2346. procedure TEnemyMeteor.DoMove(MoveCount: Integer);
  2347. begin
  2348.   X := X - MoveCount*(250/1000);
  2349.   if X < -Width then Dead;
  2350. end;
  2351.  
  2352. procedure TEnemyMeteor.HitEnemy(ADead: Boolean);
  2353. begin
  2354.   if ADead then Collisioned := True;
  2355.   MainForm.PlaySound('Hit', False);
  2356. end;
  2357.  
  2358. {procedure TMainForm.StopMusic;
  2359. begin
  2360.   PauseMusic(FMusic);
  2361.   MCISendString(pchar('seek "'+FDirectory+'Musik\Boss.mid" to start'), nil, 255, 0);
  2362.   MCISendString(pchar('seek "'+FDirectory+'Musik\Game.mid" to start'), nil, 255, 0);
  2363.   MCISendString(pchar('seek "'+FDirectory+'Musik\Title.mid" to start'), nil, 255, 0);
  2364.   MCISendString(pchar('seek "'+FDirectory+'Musik\Scene.mid" to start'), nil, 255, 0);
  2365. end;}
  2366.  
  2367. procedure TMainForm.ResumeMusic(Name: TMusicTrack);
  2368. begin
  2369.   if not OptionMusic.checked then exit;
  2370.   if Name = mtBoss then
  2371.     MCISendString(pchar('play "'+FDirectory+'Musik\Boss.mid"'), nil, 255, 0);
  2372.   if Name = mtGame then
  2373.     MCISendString(pchar('play "'+FDirectory+'Musik\Game.mid"'), nil, 255, 0);
  2374.   if Name = mtScene then
  2375.     MCISendString(pchar('play "'+FDirectory+'Musik\Scene.mid"'), nil, 255, 0);
  2376.   if Name = mtTitle then
  2377.     MCISendString(pchar('play "'+FDirectory+'Musik\Title.mid"'), nil, 255, 0);
  2378. end;
  2379.  
  2380. constructor TEnemyMeteor.Create(AParent: TSprite);
  2381. begin
  2382.   inherited Create(AParent);
  2383.   Image := MainForm.ImageList.Items.Find('Enemy-Meteor');
  2384.   Width := Image.Width;
  2385.   Height := Image.Height;
  2386.   AnimCount := Image.PatternCount;
  2387.   AnimLooped := True;
  2388.   AnimSpeed := DEFAULT_ANIMSPEED;
  2389.   PixelCheck := True;
  2390. end;
  2391.  
  2392. procedure TMainForm.SpielstandClick(Sender: TObject);
  2393. begin
  2394.   speicherungform.showmodal;
  2395. end;
  2396.  
  2397. procedure TMainForm.NeustartClick(Sender: TObject);
  2398. begin
  2399.   FLife := Lives;
  2400.   FLevel := 1; // ???
  2401.   FScore := 0;
  2402.   ec := 0;
  2403.   StartScene(gsMain);
  2404.   PlayMusic(mtGame);
  2405. end;
  2406.  
  2407. procedure TMainForm.OptionBreitbildClick(Sender: TObject);
  2408. begin
  2409.   OptionBreitbild.Checked := not OptionBreitbild.Checked;
  2410.   DXInit;
  2411.   writeoptions;
  2412. end;
  2413.  
  2414. procedure TMainForm.LeichtClick(Sender: TObject);
  2415. begin
  2416.   leicht.checked := true;
  2417.   FInterval := giLeicht;
  2418.   writeoptions;
  2419. end;
  2420.  
  2421. procedure TMainForm.MittelClick(Sender: TObject);
  2422. begin
  2423.   mittel.checked := true;
  2424.   FInterval := giMittel;
  2425.   writeoptions;
  2426. end;
  2427.  
  2428. procedure TMainForm.SchwerClick(Sender: TObject);
  2429. begin
  2430.   schwer.checked := true;
  2431.   FInterval := giSchwer;
  2432.   writeoptions;
  2433. end;
  2434.  
  2435. procedure TMainForm.FormShow(Sender: TObject);
  2436. begin
  2437.   SplashForm.Hide;
  2438.   SplashForm.Free;
  2439.  
  2440.   dxtimer.Enabled := true;
  2441.   dxtimer.ActiveOnly := true;
  2442. end;
  2443.  
  2444. procedure TMainForm.InformationenClick(Sender: TObject);
  2445. begin
  2446.   dxtimer.enabled := false;
  2447.   InfoForm.showmodal;
  2448.   if not mainform.gamepause.checked then mainform.dxtimer.enabled := true;
  2449. end;
  2450.  
  2451. procedure TMainForm.CheatClick(Sender: TObject);
  2452. begin
  2453.   CheatForm.showmodal;
  2454. end;
  2455.  
  2456. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  2457. begin
  2458.   if optionMusic.checked then DestroyMusic(FMusic);
  2459.   SpriteEngine.Engine.Clear;
  2460.   dxsound.Finalize;
  2461.   dxinput.Destroy;
  2462.   DXTimer.Enabled := False;
  2463. end;
  2464.  
  2465. procedure TMainForm.FormDestroy(Sender: TObject);
  2466. begin
  2467.   imagelist.free;
  2468.   spriteengine.free;
  2469.   dxdraw.Free;
  2470.   wavelist.free;
  2471.   dxsound.free;
  2472.   //dxinput.free;
  2473.   dxtimer.Free;
  2474. end;
  2475.  
  2476. end.
  2477.  
  2478.