Subversion Repositories spacemission

Rev

Rev 6 | Rev 14 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 daniel-mar 1
unit LevMain;
2
 
3
interface
4
 
5
uses
6
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, MMSystem,
7
  Dialogs, StdCtrls, ExtCtrls, Menus, DIB, DXClass, DXSprite, DXDraws,
6 daniel-mar 8
  DXSounds, Spin, ComCtrls{$IF CompilerVersion >= 23.0}, System.UITypes,
9
  WinAPI.DirectDraw{$ELSE}, DirectX{$IFEND};
1 daniel-mar 10
 
11
type
12
  TMainForm = class(TDXForm)
13
    MainMenu: TMainMenu;
14
    Spiel: TMenuItem;
15
    Beenden: TMenuItem;
16
    Hilfe: TMenuItem;
17
    Leer1: TMenuItem;
18
    Level: TMenuItem;
19
    Informationen: TMenuItem;
20
    Enemy1: TRadioButton;
21
    Enemy2: TRadioButton;
22
    Enemy3: TRadioButton;
23
    Enemy4: TRadioButton;
24
    Enemy5: TRadioButton;
25
    Enemy6: TRadioButton;
26
    Enemy7: TRadioButton;
27
    ScrollBar: TScrollBar;
28
    Bevel1: TBevel;
29
    Bevel2: TBevel;
30
    SelLabel: TLabel;
31
    SelPanel: TPanel;
32
    Bevel3: TBevel;
33
    SLabel1a: TLabel;
34
    SLabel2a: TLabel;
35
    SLabel1b: TLabel;
36
    SLabel2b: TLabel;
37
    SLabel0: TLabel;
38
    Neu: TMenuItem;
39
    Image1: TImage;
40
    SLabel3a: TLabel;
41
    SLabel3b: TLabel;
42
    SLabel4a: TLabel;
43
    SLabel4b: TLabel;
44
    LivesLabel: TLabel;
45
    Quelltext1: TMenuItem;
46
    StatusBar: TStatusBar;
47
    N1: TMenuItem;
48
    Spielfelderweitern1: TMenuItem;
49
    LivesEdt: TEdit;
50
    Lives: TUpDown;
51
    procedure DXDrawFinalize(Sender: TObject);
52
    procedure DXDrawInitialize(Sender: TObject);
53
    procedure FormCreate(Sender: TObject);
54
    procedure DXTimerTimer(Sender: TObject; LagCount: Integer);
55
    procedure BeendenClick(Sender: TObject);
56
    procedure FormDestroy(Sender: TObject);
57
    procedure LevelClick(Sender: TObject);
58
    procedure FormShow(Sender: TObject);
59
    procedure InformationenClick(Sender: TObject);
60
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
61
    procedure DXDrawMouseDown(Sender: TObject; Button: TMouseButton;
62
      Shift: TShiftState; X, Y: Integer);
63
    procedure EnemyClick(Sender: TObject);
64
    procedure EnemyAdd(x, y, art, lives: integer);
65
    procedure NeuClick(Sender: TObject);
66
    procedure DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X,
67
      Y: Integer);
68
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
69
    procedure Quelltext1Click(Sender: TObject);
70
    procedure Spielfelderweitern1Click(Sender: TObject);
71
    procedure ScrollBarScroll(Sender: TObject; ScrollCode: TScrollCode;
72
      var ScrollPos: Integer);
73
    procedure LivesClick(Sender: TObject; Button: TUDBtnType);
74
    procedure LivesEdtKeyPress(Sender: TObject; var Key: Char);
75
    procedure LivesEdtChange(Sender: TObject);
76
  public
77
    { VCL-Ersatz }
78
    spriteengine: tdxspriteengine;
79
    dxtimer: tdxtimer;
80
    imagelist: tdximagelist;
81
    dxdraw: tdxdraw;
82
    { Variablen }
83
    FMenuItem: integer;
84
    Enemys: TStrings;
85
    ArtChecked: integer;
86
    LiveEdit: integer;
87
    ScrollP: integer;
88
    AltScrollPos: integer;
89
    Boss: boolean;
90
    LevChanged: boolean;
91
    NumEnemys: integer;
92
    { Level-Routinen }
93
    procedure EnemyCreate(x, y: integer);
94
    procedure DestroyLevel;
95
    procedure AnzeigeAct;
96
    { Initialisiations-Routinen }
97
    procedure DXInit;
98
    procedure ProgramInit;
99
    { Farb-Routinen }
100
    function ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
101
    procedure PalleteAnim(Col: TRGBQuad; Time: Integer);
102
    { Sonstiges }
103
    procedure LivesChange(newval: integer);
104
  end;
105
 
106
var
107
  MainForm: TMainForm;
108
 
109
implementation
110
 
111
uses
4 daniel-mar 112
  Global, LevSplash, LevSpeicherung, ComInfo, LevSource, LevOptions;
1 daniel-mar 113
 
114
const
115
  FileError = 'Die Datei kann von SpaceMission nicht geöffnet werden!';
116
  status_info = ' Zeigen Sie mit dem Mauszeiger auf eine Einheit, um deren Eigenschaften anzuzeigen...';
117
  status_lives = ' Leben: ';
118
  status_nolives = ' Einheit hat keine Lebensangabe';
119
  RasterW = 48;
120
  RasterH = 32;
121
 
122
{$R *.DFM}
123
 
124
type
125
  TBackground = class(TBackgroundSprite)
126
  protected
127
    procedure DoMove(MoveCount: Integer); override;
128
  end;
129
 
130
  TEnemy = class(TImageSprite)
131
  private
132
    Lives: integer;
133
    Art: integer;
134
    XCor: integer;
135
    CorInit: boolean;
136
  protected
137
    procedure DoMove(MoveCount: Integer); override;
138
  public
139
    constructor Create(AParent: TSprite); override;
140
  end;
141
 
142
procedure TMainForm.DXInit;
143
begin
144
  Imagelist.Items.LoadFromFile(FDirectory+'DirectX\Graphic.dxg');
145
  ImageList.Items.MakeColorTable;
146
  DXDraw.ColorTable := ImageList.Items.ColorTable;
147
  DXDraw.DefColorTable := ImageList.Items.ColorTable;
148
  DXDraw.UpdatePalette;
149
  DXDraw.Initialize;
150
end;
151
 
152
procedure TEnemy.DoMove(MoveCount: Integer);
153
begin
154
  if not CorInit then
155
  begin
156
    XCor := trunc(x) + (MainForm.ScrollP * RasterW);
157
    CorInit := true;
158
  end;
159
  if MainForm.Enemys.IndexOf(floattostr(XCor)+'-'+floattostr(y)+':'+
160
    inttostr(Art)+'('+inttostr(Lives)+')') = -1 then dead;
161
  X := XCor - (MainForm.ScrollP * RasterW);
162
end;
163
 
164
procedure TBackground.DoMove(MoveCount: Integer);
165
begin
166
  X := -(MainForm.ScrollP * RasterW);
167
end;
168
 
169
constructor TEnemy.Create(AParent: TSprite);
170
begin
171
  inherited Create(AParent);
172
  if MainForm.ArtChecked = 1 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker');
173
  if MainForm.ArtChecked = 2 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker2');
174
  if MainForm.ArtChecked = 3 then Image := MainForm.ImageList.Items.Find('Enemy-Attacker3');
175
  if MainForm.ArtChecked = 4 then Image := MainForm.ImageList.Items.Find('Enemy-Meteor');
176
  if MainForm.ArtChecked = 5 then Image := MainForm.ImageList.Items.Find('Enemy-Disk');
177
  if MainForm.ArtChecked = 6 then Image := MainForm.ImageList.Items.Find('Enemy-Disk2');
178
  if MainForm.ArtChecked = 7 then Image := MainForm.ImageList.Items.Find('Enemy-Boss');
179
  if MainForm.ArtChecked = 4 then Lives := 0 else Lives := MainForm.LiveEdit;
180
  Art := MainForm.ArtChecked;
181
  Width := Image.Width;
182
  Height := Image.Height;
183
  PixelCheck := True;
184
end;
185
 
186
procedure TMainForm.FormCreate(Sender: TObject);
187
var
188
  Ergebnis: string;
189
  daten: textfile;
190
  ok: boolean;
191
begin
192
  { VCL-Ersatz start }
193
  dxtimer := tdxtimer.create(self);
194
  dxtimer.Interval := 100;
195
  dxtimer.ActiveOnly := false;
196
  dxtimer.Enabled := false;
197
  dxtimer.OnTimer := DxTimerTimer;
198
 
199
  dxdraw := tdxdraw.Create(self);
200
  dxdraw.Parent := self;
201
  dxdraw.Left := 0;
202
  dxdraw.Top := 0;
203
  dxdraw.Width := 640;
204
  dxdraw.Height := 480;
205
  dxdraw.AutoInitialize := False;
206
  dxdraw.AutoSize := False;
207
  dxdraw.Color := clBlack;
208
  dxdraw.Display.BitCount := 24;
209
  dxdraw.Display.FixedBitCount := False;
210
  dxdraw.Display.FixedRatio := False;
211
  dxdraw.Display.FixedSize := False;
212
  dxdraw.Display.Height := 600;
213
  dxdraw.Display.Width := 800;
4 daniel-mar 214
  dxdraw.Options := [doAllowReboot, doWaitVBlank, doAllowPalette256, doCenter, {doRetainedMode,} doHardware, doSelectDriver];
1 daniel-mar 215
  dxdraw.OnFinalize := DXDrawFinalize;
216
  dxdraw.OnInitialize := DXDrawInitialize;
217
  dxdraw.ParentShowHint := False;
218
  dxdraw.ShowHint := False;
219
  dxdraw.TabOrder := 0;
220
  dxdraw.OnMouseDown := DXDrawMouseDown;
221
  dxdraw.OnMouseMove := DXDrawMouseMove;
222
 
223
  spriteengine := tdxspriteengine.create(self);
224
  spriteengine.DXDraw := dxdraw;
225
 
226
  imagelist := tdximagelist.create(self);
227
  imagelist.DXDraw := dxdraw;
228
 
229
  { VCL-Ersatz ende }
230
 
231
  ArtChecked := 1;
232
  LiveEdit := 1;
233
  // Leeres Level am Anfang braucht keine Beenden-Bestätigung.
234
  // LevChanged := true;
2 daniel-mar 235
 
236
  //Application.Title := 'SpaceMission '+ProgramVersion+' - Leveleditor';
237
  Caption := 'SpaceMission '+ProgramVersion+' - Leveleditor';
1 daniel-mar 238
  DXInit;
239
  if (paramcount > 0) and (fileexists(paramstr(1))) then
240
  begin
241
    AssignFile(daten, paramstr(1));
242
    Reset(daten);
243
    ok := true;
244
    ReadLN(daten, Ergebnis);
245
    if Ergebnis <> '; SpaceMission '+FCompVersion then ok := false;
246
    ReadLN(daten, Ergebnis);
247
    if ergebnis <> '; LEV-File' then ok := false;
248
    if not ok then
249
    begin
250
      showmessage(FileError);
251
      CloseFile(daten);
252
      ProgramInit;
253
      exit;
254
    end;
255
    { Laden }
256
    CloseFile(daten);
257
    exit;
258
  end;
259
  if fileexists(fdirectory+'Bilder\Auswahl.bmp') then
260
    Image1.Picture.LoadFromFile(fdirectory+'Bilder\Auswahl.bmp');
261
  {else
262
    SelPanel.visible := false;}
263
  ProgramInit;
264
end;
265
 
266
procedure TMainForm.FormDestroy(Sender: TObject);
267
begin
268
  Enemys.Free;
269
  //spriteengine.Free;
270
  dxtimer.Free;
271
  imagelist.Free;
272
  dxdraw.free;
273
end;
274
 
275
procedure TMainForm.BeendenClick(Sender: TObject);
276
begin
277
  close;
278
end;
279
 
280
procedure TMainForm.DXDrawInitialize(Sender: TObject);
281
begin
282
  DXTimer.Enabled := True;
283
end;
284
 
285
procedure TMainForm.DXDrawFinalize(Sender: TObject);
286
begin
287
  DXTimer.Enabled := False;
288
end;
289
 
290
procedure TMainForm.DXTimerTimer(Sender: TObject; LagCount: Integer);
291
begin
292
  if not DXDraw.CanDraw then exit;
293
  LagCount := 1000 div 60;
294
  SpriteEngine.Move(LagCount);
295
  SpriteEngine.Dead;
296
  DxDraw.Surface.Fill(0);
297
  SpriteEngine.Draw;
298
  DXDraw.Flip;
299
end;
300
 
301
function TMainForm.ComposeColor(Dest, Src: TRGBQuad; Percent: Integer): TRGBQuad;
302
begin
303
  with Result do
304
  begin
305
    rgbRed := Src.rgbRed+((Dest.rgbRed-Src.rgbRed)*Percent div 256);
306
    rgbGreen := Src.rgbGreen+((Dest.rgbGreen-Src.rgbGreen)*Percent div 256);
307
    rgbBlue := Src.rgbBlue+((Dest.rgbBlue-Src.rgbBlue)*Percent div 256);
308
    rgbReserved := 0;
309
  end;
310
end;
311
 
312
procedure TMainForm.PalleteAnim(Col: TRGBQuad; Time: Integer);
313
var
314
  i: Integer;
315
  t, t2: DWORD;
316
  ChangePalette: Boolean;
317
  c: Integer;
318
begin
319
  if DXDraw.Initialized then
320
  begin
321
    c := DXDraw.Surface.ColorMatch(RGB(Col.rgbRed, Col.rgbGreen, Col.rgbBlue));
322
    ChangePalette := False;
323
    if DXDraw.CanPaletteAnimation then
324
    begin
325
      t := GetTickCount;
326
      while Abs(GetTickCount-t)<Time do
327
      begin
328
        t2 := Trunc(Abs(GetTickCount-t)/Time*255);
329
        for i := 0 to 255 do
330
          DXDraw.ColorTable[i] := ComposeColor(Col, DXDraw.DefColorTable[i], t2);
331
        DXDraw.UpdatePalette;
332
        ChangePalette := True;
333
      end;
334
    end else
335
      Sleep(Time);
336
    for i := 0 to 4 do
337
    begin
338
      DXDraw.Surface.Fill(c);
339
      DXDraw.Flip;
340
    end;
341
    if ChangePalette then
342
    begin
343
      DXDraw.ColorTable := DXDraw.DefColorTable;
344
      DXDraw.UpdatePalette;
345
    end;
346
    DXDraw.Surface.Fill(c);
347
    DXDraw.Flip;
348
  end;
349
end;
350
 
351
procedure TMainForm.ProgramInit;
352
{var
353
  i, j: Integer;}
354
begin
355
  Enemys := TStringList.create;
356
  sleep(500);
357
  //PlayerSprite
358
  with TBackground.Create(SpriteEngine.Engine) do
359
  begin
360
    SetMapSize(1, 1);
361
    Image := mainform.ImageList.Items.Find('Star3');
362
    Z := -13;
363
    Y := 40;
364
    Tile := True;
365
  end;
366
  with TBackground.Create(SpriteEngine.Engine) do
367
  begin
368
    SetMapSize(1, 1);
369
    Image := mainform.ImageList.Items.Find('Star2');
370
    Z := -12;
371
    Y := 30;
372
    Tile := True;
373
  end;
374
  with TBackground.Create(SpriteEngine.Engine) do
375
  begin
376
    SetMapSize(1, 1);
377
    Image := mainform.ImageList.Items.Find('Star1');
378
    Z := -11;
379
    Y := 10;
380
    Tile := True;
381
  end;
382
  with TBackground.Create(SpriteEngine.Engine) do
383
  begin
384
    SetMapSize(1, 1);
385
    Image := mainform.ImageList.Items.Find('Matrix');
386
    Z := -10;
387
    Tile := True;
388
  end;
389
  {with TBackground.Create(SpriteEngine.Engine) do
390
  begin
391
    SetMapSize(200, 10);
392
    Y := 10;
393
    Z := -13;
394
    FSpeed := 1 / 2;
395
    Tile := True;
396
    for i := 0 to MapHeight-1 do
397
    begin
398
      for j := 0 to MapWidth-1 do
399
      begin
400
        Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 8);
401
        if Random(100)<95 then Chips[j, i] := -1;
402
      end;
403
    end;
404
  end;
405
  with TBackground.Create(SpriteEngine.Engine) do
406
  begin
407
    SetMapSize(200, 10);
408
    Y := 30;
409
    Z := -12;
410
    FSpeed := 1;
411
    Tile := True;
412
    for i := 0 to MapHeight-1 do
413
    begin
414
      for j := 0 to MapWidth-1 do
415
      begin
416
        Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 4);
417
        if Random(100)<95 then Chips[j, i] := -1;
418
      end;
419
    end;
420
  end;
421
  with TBackground.Create(SpriteEngine.Engine) do
422
  begin
423
    SetMapSize(200, 10);
424
    Y := 40;
425
    Z := -11;
426
    FSpeed := 2;
427
    Tile := True;
428
    for i := 0 to MapHeight-1 do
429
    begin
430
      for j := 0 to MapWidth-1 do
431
      begin
432
        Chips[j, i] := Image.PatternCount-Random(Image.PatternCount div 2);
433
        if Random(100)<95 then Chips[j, i] := -1;
434
      end;
435
    end;
436
  end;}
437
  PalleteAnim(RGBQuad(0, 0, 0), 300);
438
  mainform.Visible := true;
439
end;
440
 
441
procedure TMainForm.LevelClick(Sender: TObject);
442
begin
443
  speicherungform.showmodal;
444
end;
445
 
446
procedure TMainForm.FormShow(Sender: TObject);
447
begin
448
  SplashForm.Hide;
449
  SplashForm.Free;
450
 
451
  dxtimer.Enabled := true;
452
  dxtimer.ActiveOnly := true;
453
end;
454
 
455
procedure TMainForm.InformationenClick(Sender: TObject);
456
begin
3 daniel-mar 457
  mainform.dxtimer.enabled := false;
1 daniel-mar 458
  InfoForm.showmodal;
3 daniel-mar 459
  mainform.dxtimer.enabled := true;
1 daniel-mar 460
end;
461
 
462
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
463
begin
464
  SpriteEngine.Engine.Clear;
465
  DXTimer.Enabled := False;
466
end;
467
 
468
procedure TMainForm.DXDrawMouseDown(Sender: TObject; Button: TMouseButton;
469
  Shift: TShiftState; X, Y: Integer);
470
var
471
  i, j, k, l, ex, ey: integer;
472
  ok, breaked: boolean;
473
begin
474
  ex := trunc(x/RasterW) * RasterW;
475
  ey := trunc(y/RasterH) * RasterH;
476
  EnemyCreate(ex, ey);
477
  breaked := false;
478
  { Setzen }
479
  if Button = mbLeft then
480
  begin
481
    ok := true;
482
    if (ArtChecked = 7) and boss then ok := false
483
    else
484
    begin
485
      for i := 1 to 7 do
486
      begin
487
        for j := 0 to 999 do
488
        begin
489
          if boss then
490
          begin
491
            for k := 0 to 3 do
492
            begin
493
              for l := 0 to 1 do
494
              begin
495
                if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':7('+inttostr(j)+')') <> -1 then
496
                begin
497
                  ok := false;
498
                  break;
499
                end;
500
              end;
501
              if not ok then break;
502
            end;
503
            if not ok then break;
504
          end;
505
          if Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
506
            inttostr(i)+'('+inttostr(j)+')') <> -1 then
507
          begin
508
            ok := false;
509
            break;
510
          end;
511
        end;
512
        if not ok then break;
513
      end;
514
    end;
515
    if ok then
516
    begin
517
      if ArtChecked <> 4 then
518
        Enemys.Add(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
519
          inttostr(ArtChecked)+'('+inttostr(LiveEdit)+')')
520
      else
521
        Enemys.Add(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
522
          inttostr(ArtChecked)+'(0)');
523
      inc(NumEnemys);
524
      if ArtChecked = 7 then boss := true;
525
    end
526
    else beep;
527
  end
528
  { Löschen }
529
  else if Button = mbRight then
530
  begin
531
    for i := 1 to 7 do
532
    begin
533
      for j := 0 to 999 do
534
      begin
535
        if boss and (i = 7) then
536
        begin
537
          for k := 0 to 3 do
538
          begin
539
            for l := 0 to 1 do
540
            begin
541
              if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')') <> -1 then
542
              begin
543
                Enemys.Delete(Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')'));
544
                Boss := false;
545
                dec(NumEnemys);
546
                breaked := true;
547
                break;
548
              end;
549
            end;
550
            if breaked then break;
551
          end;
552
        end;
553
        if Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
554
          inttostr(i)+'('+inttostr(j)+')') <> -1 then
555
        begin
556
          Enemys.Delete(Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+
557
            ':'+inttostr(i)+'('+inttostr(j)+')'));
558
          if i = 7 then Boss := false;
559
          dec(NumEnemys);
560
          breaked := true;
561
          break;
562
        end;
563
      end;
564
      if breaked then break;
565
    end;
566
  end;
567
  LevChanged := true;
568
  AnzeigeAct;
569
end;
570
 
571
procedure TMainForm.EnemyClick(Sender: TObject);
572
begin
573
  if sender = Enemy1 then ArtChecked := 1;
574
  if sender = Enemy2 then ArtChecked := 2;
575
  if sender = Enemy3 then ArtChecked := 3;
576
  if sender = Enemy4 then ArtChecked := 4;
577
  if sender = Enemy5 then ArtChecked := 5;
578
  if sender = Enemy6 then ArtChecked := 6;
579
  if sender = Enemy7 then ArtChecked := 7;
580
  Image1.Left := -(87 * (ArtChecked - 1)) + 1;
581
  Lives.Enabled := sender <> Enemy4;
582
  LivesLabel.Enabled := sender <> Enemy4;
583
  if sender = Enemy4 then LivesEdt.Font.Color := clBtnShadow // andere farbe?
584
    else LivesEdt.Font.Color := clWindowText;
585
end;
586
 
587
procedure TMainForm.EnemyCreate(x, y: integer);
588
var
589
  Enemy: TSprite;
590
begin
591
  Enemy := TEnemy.Create(SpriteEngine.Engine);
592
  Enemy.x := x;
593
  Enemy.y := y;
594
end;
595
 
596
procedure TMainForm.DestroyLevel;
597
begin
8 daniel-mar 598
  ScrollBar.Position := 0; // this doesn't call ScrollBarScroll()
599
  ScrollP := 0;
1 daniel-mar 600
  Enemys.Clear;
601
  NumEnemys := 0;
602
  Boss := false;
603
  LevChanged := true;
604
  Lives.Position := 1;
605
  LivesChange(Lives.Position);
606
  Enemy1.Checked := true;
607
  EnemyClick(Enemy1);
608
  AnzeigeAct;
609
end;
610
 
611
procedure TMainForm.AnzeigeAct;
612
begin
613
  SLabel1b.Caption := inttostr(NumEnemys);
614
  if Boss then SLabel2b.Caption := 'Ja' else SLabel2b.Caption := 'Nein';
615
  SLabel3b.Caption := inttostr(ScrollBar.Max);
616
  if LevChanged then
617
  begin
618
    SLabel4a.Font.Color := $00000096;
619
    SLabel4b.Font.Color := $00000096;
620
    SLabel4b.Caption := 'Nein';
621
  end
622
  else
623
  begin
624
    SLabel4a.Font.Color := $00009600;
625
    SLabel4b.Font.Color := $00009600;
626
    SLabel4b.Caption := 'Ja';
627
  end;
628
end;
629
 
630
procedure TMainForm.EnemyAdd(x, y, art, lives: integer);
631
begin
632
  Enemys.Add(inttostr(x)+'-'+inttostr(y)+':'+inttostr(art)+'('+inttostr(lives)+')');
633
end;
634
 
635
procedure TMainForm.NeuClick(Sender: TObject);
636
begin
637
  if MessageDlg('Level wirklich löschen?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
638
    DestroyLevel;
639
end;
640
 
641
procedure TMainForm.DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X,
642
  Y: Integer);
643
var
644
  ex, ey, i, j, k, l, wert: integer;
645
  breaked: boolean;
646
begin
647
  if sender <> DxDraw then
648
  begin
649
    StatusBar.SimpleText := status_info;
650
    exit;
651
  end;
652
  ex := trunc(x/RasterW) * RasterW;
653
  ey := trunc(y/RasterH) * RasterH;
654
  wert := -1;
655
  breaked := false;
656
  for i := 1 to 7 do
657
  begin
658
    for j := 0 to 999 do
659
    begin
660
      if boss and (i = 7) then
661
      begin
662
        for k := 0 to 3 do
663
        begin
664
          for l := 0 to 1 do
665
          begin
666
            if Enemys.IndexOf(floattostr(ex + ((ScrollP - k) * RasterW))+'-'+floattostr(ey - (RasterH * l))+':'+inttostr(i)+'('+inttostr(j)+')') <> -1 then
667
            begin
668
              wert := j;
669
              breaked := true;
670
              break;
671
            end;
672
          end;
673
          if breaked then break;
674
        end;
675
      end;
676
      if (breaked = false) and (Enemys.IndexOf(floattostr(ex + (ScrollP * RasterW))+'-'+floattostr(ey)+':'+
677
        inttostr(i)+'('+inttostr(j)+')') <> -1) then
678
      begin
679
        wert := j;
680
        breaked := true;
681
        break;
682
      end;
683
    end;
684
    if breaked then break;
685
  end;
686
  if wert <> -1 then
687
  begin
688
    if wert > 0 then
689
      StatusBar.SimpleText := status_lives + inttostr(wert)
690
    else
691
      StatusBar.SimpleText := status_nolives;
692
  end
693
  else
694
    StatusBar.SimpleText := status_info;
695
end;
696
 
697
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
698
begin
699
  if LevChanged then
700
    CanClose := MessageDlg('Beenden ohne abspeichern?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
701
end;
702
 
703
procedure TMainForm.Quelltext1Click(Sender: TObject);
704
begin
705
  SourceForm.Aktualisieren;
706
  SourceForm.showmodal;
707
end;
708
 
709
procedure TMainForm.Spielfelderweitern1Click(Sender: TObject);
710
begin
711
  LevelForm.Aktualisieren;
712
  LevelForm.showmodal;
713
end;
714
 
715
procedure TMainForm.ScrollBarScroll(Sender: TObject;
716
  ScrollCode: TScrollCode; var ScrollPos: Integer);
717
begin
718
  ScrollP := ScrollPos;
719
end;
720
 
721
procedure TMainForm.LivesChange(newval: integer);
722
begin
723
  LiveEdit := newval;
724
  livesedt.Text := inttostr(LiveEdit);
725
  lives.Position := newval;
726
end;
727
 
728
procedure TMainForm.LivesClick(Sender: TObject; Button: TUDBtnType);
729
begin
730
  LivesChange(lives.Position);
731
end;
732
 
733
procedure TMainForm.LivesEdtKeyPress(Sender: TObject; var Key: Char);
734
begin
735
  if not (Key in [#13, #08, '0'..'9']) then
736
    Key := #0;
737
end;
738
 
739
procedure TMainForm.LivesEdtChange(Sender: TObject);
740
begin
741
  LivesChange(strtoint(livesedt.text));
742
end;
743
 
744
end.
745