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