-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathuatomic_field.pas
More file actions
2002 lines (1919 loc) · 80.3 KB
/
uatomic_field.pas
File metadata and controls
2002 lines (1919 loc) · 80.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(******************************************************************************)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* This file is part of FPC_Atomic *)
(* *)
(* See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(******************************************************************************)
Unit uatomic_field;
{$MODE ObjFPC}{$H+}
Interface
Uses
Classes, SysUtils
{$IFDEF Client}
, uopengl_animation
, uatomic
{$ENDIF}
, uatomic_common
{$IFDEF Server}
, ufifo, uvectormath
, uai_types
{$ENDIF}
;
Type
{$IFDEF Server}
TIntFifo = specialize TBufferedFifo < Integer > ;
TPointFifo = specialize TBufferedFifo < Tpoint > ;
TPlaySoundEffectCallback = Procedure(PlayerIndex: integer; Effect: TSoundEffect) Of Object;
{$ENDIF}
{$IFDEF Client}
TBrickAnimation = Record
ani: TOpenGL_Animation;
Active: Boolean;
End;
{$ENDIF}
{ TAtomicField }
TAtomicField = Class
private
{$IFDEF Server}
fBombsEnabled: Boolean;
fBombs: Array[0..FieldWidth * FieldHeight - 1] Of TBombInfo; // Das Array ist eigentlich hoch Dynamisch, aber so allokieren wir nicht andauernd neuen Speicher
fBombCount: Integer;
fBombDetonateFifo: TIntFifo;
fPowerUpClearFifo: TPointFifo;
fPlaySoundEffect: TPlaySoundEffectCallback;
fHurryIndex: integer; // Der Index in der HurryCoords Konstante, wenn Hurry Aktiv ist.
{$ENDIF}
fHasArrows: Boolean; // Wenn True, dann hat die Karte die Lustigen Pfeilchen auf denen die Bomben hin und her geschubst werden..
fArrowDirs: Array[0..FieldWidth - 1, 0..FieldHeight - 1] Of integer; // Die Richtungen der "Pfeile" -1 = Aus, 0, 90, 180, 270 = Winkel
fHasConveyors: Boolean; // Wenn True, dann hat die Karte diese Blauen Fließbänder auf denen Spieler und Bomben automatisch bewegt werden (geschwindigkeit via Settings einstellbar)
fConveyorDirs: Array[0..FieldWidth - 1, 0..FieldHeight - 1] Of integer; // Die Richtungen der "Pfeile" -1 = Aus, 0, 90, 180, 270 = Winkel
{$IFDEF Client}
fFieldTex, fBrickTex, fSolidTex: integer;
fxBricks: Array[0..FieldWidth - 1, 0..FieldHeight - 1] Of TBrickAnimation;
fxBrickAniTime: integer;
fPreviewLines: Array[0..4] Of String;
fArrows, fConveyors: TOpenGL_Animation;
{$ENDIF}
fSoundFile: String;
fHash: Uint64; // Wird beim laden der Karte berechnet, dient zur Identifizierung auf "Gleichheit"
fField: TFieldBricks;
{$IFDEF Client}
Procedure RenderBlock(x, y: integer; Brick: TBrickData);
Function OnxBrickOverflow(Sender: TObject): Boolean;
{$ENDIF}
{$IFDEF Server}
(*
* False, wenn der Strahl gestoppt wird und nicht mehr "weiter" Laufen darf
*)
Function Detonate(x, y: integer; PlayerIndex, ColorIndex: integer; Flame: TFlame): Boolean;
Function FielWalkable(x, y: integer; AlsoCheckPowerUps: Boolean): Boolean;
{$ENDIF}
public
Name: String;
Available: Boolean; // Wenn True, dann kann die Karte verwendet werden und Alle Spieler haben sie.
{$IFDEF Server}
StatisticCallback: TStatisticCallback;
Property BombsEnabled: Boolean read fBombsEnabled;
{$ENDIF}
Property Hash: UInt64 read fHash; // Pseudo MD5Hash über alle Dateien der Karte
Property Sound: String read fSoundFile;
Constructor Create(
{$IFDEF Server}
PlaySoundEffectCallback: TPlaySoundEffectCallback;
sStatisticCallback: TStatisticCallback
{$ENDIF}
); virtual;
Destructor Destroy(); override;
Function loadFromDirectory(Dir: String
{$IFDEF Client}
; aArrows: TOpenGL_Animation; aConveyors: TOpenGL_Animation
{$ENDIF}
): Boolean;
{$IFDEF Client}
Procedure RenderPreview; virtual;
Procedure Render(Const Atomics: TAtomics; PowerTexs: TPowerTexArray);
Procedure ReadGameingData(Const Stream: TStream);
Procedure Reset(); // Wie Initialize nur eben die Client version
{$ENDIF}
{$IFDEF Server}
Procedure Initialize(Const Players: TPlayers; Const Scheme: TScheme); // Setzt die Spielerpositionen gleich mit
Procedure AppendGamingData(Const Stream: TStream);
Function HandleMovePlayer(Var Players: TPlayers; PlayerIndex: integer; ConveyorSpeed: TConveyorSpeed): Boolean; // True, wenn der Spieler gestorben ist.
Procedure HandleActionPlayer(Var Player: TPlayer; PlayerIndex: integer);
Procedure HandleBombs(Var Players: TPlayers; PreHurry: Boolean; ConveyorSpeed: TConveyorSpeed);
Procedure HandlePlayerVsMap(Var Players: TPlayers;
PlayerGetsPowerUp: TPlayerGetsPowerUpEvent);
Procedure HandleFieldAnims;
Procedure DisableAllBombs();
Function GetAiInfo(Const Players: TPlayers; TeamPlay: Boolean): TaiInfo;
Procedure IncHurry();
Procedure KillPlayer(Var Players: TPlayers; Index: integer); // Ohne Punktewertung
Procedure RepopulatePlayersCollectedPowerUps(Const Players: TPlayers; PlayerIndex: Integer);
{$ENDIF}
End;
{ TAtomicRandomField }
TAtomicRandomField = Class(TAtomicField)
private
{$IFDEF Client}
fPreviewGrid: Array[0..4, 0..4] Of Integer;
{$ENDIF}
public
{$IFDEF Client}
Procedure CreatePreview(Const Fields: Array Of TAtomicField);
Procedure RenderPreview; override;
{$ENDIF}
End;
Implementation
Uses
Graphics, IniFiles, md5
{$IFDEF server}
, math
{$ENDIF}
{$IFDEF Client}
, uvectormath
, dglOpenGL
, uopengl_graphikengine
, ugraphics
{$ENDIF}
;
{$IFDEF server}
Const
(*
* Beschreibt einen Weg von Links oben schneckenmäßig im Uhrzeigersinn bis nach innen rein, bis nur noch 5 Felder in der Mitte ügrig sind.
*)
HurryCoords: Array[0..159] Of Tpoint = (
(x: 0; y: 0), (x: 1; y: 0), (x: 2; y: 0), (x: 3; y: 0), (x: 4; y: 0), (x: 5; y: 0), (x: 6; y: 0), (x: 7; y: 0), (x: 8; y: 0), (x: 9; y: 0), (x: 10; y: 0), (x: 11; y: 0), (x: 12; y: 0), (x: 13; y: 0), (x: 14; y: 0),
(x: 14; y: 1), (x: 14; y: 2), (x: 14; y: 3), (x: 14; y: 4), (x: 14; y: 5), (x: 14; y: 6), (x: 14; y: 7), (x: 14; y: 8), (x: 14; y: 9), (x: 14; y: 10),
(x: 13; y: 10), (x: 12; y: 10), (x: 11; y: 10), (x: 10; y: 10), (x: 9; y: 10), (x: 8; y: 10), (x: 7; y: 10), (x: 6; y: 10), (x: 5; y: 10), (x: 4; y: 10), (x: 3; y: 10), (x: 2; y: 10), (x: 1; y: 10), (x: 0; y: 10),
(x: 0; y: 9), (x: 0; y: 8), (x: 0; y: 7), (x: 0; y: 6), (x: 0; y: 5), (x: 0; y: 4), (x: 0; y: 3), (x: 0; y: 2), (x: 0; y: 1),
(x: 1; y: 1), (x: 2; y: 1), (x: 3; y: 1), (x: 4; y: 1), (x: 5; y: 1), (x: 6; y: 1), (x: 7; y: 1), (x: 8; y: 1), (x: 9; y: 1), (x: 10; y: 1), (x: 11; y: 1), (x: 12; y: 1), (x: 13; y: 1),
(x: 13; y: 2), (x: 13; y: 3), (x: 13; y: 4), (x: 13; y: 5), (x: 13; y: 6), (x: 13; y: 7), (x: 13; y: 8), (x: 13; y: 9),
(x: 12; y: 9), (x: 11; y: 9), (x: 10; y: 9), (x: 9; y: 9), (x: 8; y: 9), (x: 7; y: 9), (x: 6; y: 9), (x: 5; y: 9), (x: 4; y: 9), (x: 3; y: 9), (x: 2; y: 9), (x: 1; y: 9),
(x: 1; y: 8), (x: 1; y: 7), (x: 1; y: 6), (x: 1; y: 5), (x: 1; y: 4), (x: 1; y: 3), (x: 1; y: 2),
(x: 2; y: 2), (x: 3; y: 2), (x: 4; y: 2), (x: 5; y: 2), (x: 6; y: 2), (x: 7; y: 2), (x: 8; y: 2), (x: 9; y: 2), (x: 10; y: 2), (x: 11; y: 2), (x: 12; y: 2),
(x: 12; y: 3), (x: 12; y: 4), (x: 12; y: 5), (x: 12; y: 6), (x: 12; y: 7), (x: 12; y: 8),
(x: 11; y: 8), (x: 10; y: 8), (x: 9; y: 8), (x: 8; y: 8), (x: 7; y: 8), (x: 6; y: 8), (x: 5; y: 8), (x: 4; y: 8), (x: 3; y: 8), (x: 2; y: 8),
(x: 2; y: 7), (x: 2; y: 6), (x: 2; y: 5), (x: 2; y: 4), (x: 2; y: 3),
(x: 3; y: 3), (x: 4; y: 3), (x: 5; y: 3), (x: 6; y: 3), (x: 7; y: 3), (x: 8; y: 3), (x: 9; y: 3), (x: 10; y: 3), (x: 11; y: 3),
(x: 11; y: 4), (x: 11; y: 5), (x: 11; y: 6), (x: 11; y: 7),
(x: 10; y: 7), (x: 9; y: 7), (x: 8; y: 7), (x: 7; y: 7), (x: 6; y: 7), (x: 5; y: 7), (x: 4; y: 7), (x: 3; y: 7),
(x: 3; y: 6), (x: 3; y: 5), (x: 3; y: 4),
(x: 4; y: 4), (x: 5; y: 4), (x: 6; y: 4), (x: 7; y: 4), (x: 8; y: 4), (x: 9; y: 4), (x: 10; y: 4),
(x: 10; y: 5), (x: 10; y: 6),
(x: 9; y: 6), (x: 8; y: 6), (x: 7; y: 6), (x: 6; y: 6), (x: 5; y: 6), (x: 4; y: 6),
(x: 4; y: 5)
);
{$ENDIF}
{$IFDEF Client}
{ TAtomicRandomField }
Procedure TAtomicRandomField.CreatePreview(Const Fields: Array Of TAtomicField);
Var
index, i, j: Integer;
Begin
// Irgend eine Hintergrund Graphik Wählen
fFieldTex := Fields[random(Length(Fields))].fFieldTex;
// Irgend welche Bricks / Solids nehmen
For i := 0 To 4 Do Begin
For j := 0 To 4 Do Begin
index := random(Length(Fields));
If ((i = 1) And (j = 1)) Or
((i = 3) And (j = 1)) Or
((i = 1) And (j = 3)) Or
((i = 3) And (j = 3)) Then Begin
fPreviewGrid[i, j] := Fields[index].fSolidTex;
End
Else Begin
fPreviewGrid[i, j] := Fields[index].fBrickTex;
End;
End;
End;
// Ein Paar Felder sollen auch "Leer" bleiben
fPreviewGrid[0, 0] := 0;
fPreviewGrid[1, 0] := 0;
fPreviewGrid[0, 1] := 0;
fPreviewGrid[0, 3] := 0;
fPreviewGrid[1, 4] := 0;
End;
Procedure TAtomicRandomField.RenderPreview;
Var
j, i: Integer;
Begin
(*
* Die Hintergrund Graphik kann auf jeden Fall gerendert werden..
*)
glColor3f(1, 1, 1);
glpushmatrix();
glTranslatef(0, 0, atomic_Map_Layer);
RenderQuad(v2(0, 0), v2(GameWidth, GameHeight), 0, false, fFieldTex);
For j := 0 To 4 Do Begin
For i := 0 To 4 Do Begin
If fPreviewGrid[i, j] = 0 Then Continue;
glPushMatrix;
glTranslatef(Fieldxoff + i * FieldBlockWidth, FieldyOff + j * FieldBlockHeight, atomic_EPSILON);
RenderAlphaQuad(v2(FieldBlockWidth / 2, FieldBlockHeight / 2), FieldBlockWidth, -FieldBlockHeight, 0, fPreviewGrid[i, j]);
glPopMatrix;
End;
End;
glpopmatrix();
End;
{$ENDIF}
{ TAtomicField }
// Die IDE Code vervollständigung killt manchmal den Korrekten Header, deswegen hier die "Kopiervorlage"
//Constructor TAtomicField.Create(
//{$IFDEF Server}
// PlaySoundEffectCallback: TPlaySoundEffectCallback;
// sStatisticCallback: TStatisticCallback
//{$ENDIF}
// );
Constructor TAtomicField.Create(
{$IFDEF Server}
PlaySoundEffectCallback: TPlaySoundEffectCallback;
sStatisticCallback: TStatisticCallback
{$ENDIF}
);
Var
i, j: integer;
Begin
{$IFDEF Client}
For i := 0 To FieldWidth - 1 Do Begin
For j := 0 To FieldHeight - 1 Do Begin
fxBricks[i, j].ani := Nil;
End;
End;
{$ENDIF}
For i := 0 To FieldWidth - 1 Do Begin
For j := 0 To FieldHeight - 1 Do Begin
fArrowDirs[i, j] := -1;
fConveyorDirs[i, j] := -1;
End;
End;
// Alle nach Rechts
fArrowDirs[2, 0] := 0;
fArrowDirs[6, 0] := 0;
fArrowDirs[10, 0] := 0;
fArrowDirs[0, 2] := 0;
fArrowDirs[4, 2] := 0;
fArrowDirs[8, 2] := 0;
fArrowDirs[12, 2] := 0;
fArrowDirs[4, 4] := 0;
fArrowDirs[0, 6] := 0;
fArrowDirs[8, 6] := 0;
fArrowDirs[12, 6] := 0;
// Alle nach Oben
fArrowDirs[2, 2] := 90;
fArrowDirs[6, 2] := 90;
fArrowDirs[10, 2] := 90;
fArrowDirs[0, 4] := 90;
fArrowDirs[2, 6] := 90;
fArrowDirs[4, 6] := 90;
fArrowDirs[10, 6] := 90;
fArrowDirs[0, 8] := 90;
fArrowDirs[2, 10] := 90;
fArrowDirs[6, 10] := 90;
fArrowDirs[10, 10] := 90;
// Alle nach Links
fArrowDirs[2, 4] := 180;
fArrowDirs[10, 4] := 180;
fArrowDirs[14, 4] := 180;
fArrowDirs[6, 6] := 180;
fArrowDirs[2, 8] := 180;
fArrowDirs[6, 8] := 180;
fArrowDirs[10, 8] := 180;
fArrowDirs[14, 8] := 180;
fArrowDirs[4, 10] := 180;
fArrowDirs[8, 10] := 180;
fArrowDirs[12, 10] := 180;
// Alle nach unten
fArrowDirs[4, 0] := 270;
fArrowDirs[8, 0] := 270;
fArrowDirs[12, 0] := 270;
fArrowDirs[14, 2] := 270;
fArrowDirs[6, 4] := 270;
fArrowDirs[8, 4] := 270;
fArrowDirs[12, 4] := 270;
fArrowDirs[14, 6] := 270;
fArrowDirs[4, 8] := 270;
fArrowDirs[8, 8] := 270;
fArrowDirs[12, 8] := 270;
// Nach Rechts
For i := 2 To 11 Do Begin
fConveyorDirs[i, 2] := 0;
End;
// Nach Unten
For j := 2 To 7 Do Begin
fConveyorDirs[12, j] := 270;
End;
// Nach Links
For i := 3 To 12 Do Begin
fConveyorDirs[i, 8] := 180;
End;
// Nach oben
For j := 3 To 8 Do Begin
fConveyorDirs[2, j] := 90;
End;
Name := '';
fHash := 0;
{$IFDEF Server}
StatisticCallback := sStatisticCallback;
fPlaySoundEffect := PlaySoundEffectCallback;
fBombCount := 0;
fBombDetonateFifo := TIntFifo.create(128);
fPowerUpClearFifo := TPointFifo.create(128);
{$ENDIF}
End;
Destructor TAtomicField.Destroy;
{$IFDEF Client}
Var
i, j: Integer;
{$ENDIF}
Begin
{$IFDEF Client}
For i := 0 To FieldWidth - 1 Do
For j := 0 To FieldHeight - 1 Do
If assigned(fxBricks[i, j].ani) Then fxBricks[i, j].ani.free;
{$ENDIF}
{$IFDEF Server}
fBombDetonateFifo.free;
fPowerUpClearFifo.free;
{$ENDIF}
Inherited Destroy;
End;
// Die IDE Code vervollständigung killt manchmal den Korrekten Header, deswegen hier die "Kopiervorlage"
//Function TAtomicField.loadFromDirectory(Dir: String
//{$IFDEF Client}
// ; aArrows: TOpenGL_Animation; aConveyors: TOpenGL_Animation
//{$ENDIF}
// ): Boolean;
Function TAtomicField.loadFromDirectory(Dir: String
{$IFDEF Client}
; aArrows: TOpenGL_Animation; aConveyors: TOpenGL_Animation
{$ENDIF}
): Boolean;
Var
tmphash: TMD5Digest;
Procedure AppendHash;
Var
val: UInt64;
i: Integer;
Begin
val := 0;
For i := 0 To 7 Do Begin
val := val Shl 8;
val := val Or tmphash[i];
End;
fHash := fHash Xor val;
val := 0;
For i := 8 To 15 Do Begin
val := val Shl 8;
val := val Or tmphash[i];
End;
fHash := fHash Xor val;
End;
Var
ini: TIniFile;
{$IFDEF Client}
i, j: Integer;
xBrick: TOpenGL_Animation;
{$ENDIF}
Begin
result := false;
{$IFDEF Client}
fArrows := aArrows;
fConveyors := aConveyors;
{$ENDIF}
fHash := 0;
dir := IncludeTrailingPathDelimiter(dir);
If Not FileExists(dir + 'brick.png') Then exit;
{$IFDEF Client}
fBrickTex := OpenGL_GraphikEngine.LoadAlphaColorGraphik(dir + 'brick.png', ColorToRGB(clfuchsia), smStretchHard);
{$ENDIF}
tmphash := MD5File(dir + 'brick.png');
AppendHash;
If Not FileExists(dir + 'field.png') Then exit;
{$IFDEF Client}
fFieldTex := OpenGL_GraphikEngine.LoadGraphik(dir + 'field.png', smStretchHard);
{$ENDIF}
tmphash := MD5File(dir + 'field.png');
AppendHash;
If Not FileExists(dir + 'info.txt') Then exit;
ini := TIniFile.Create(dir + 'info.txt');
name := ini.ReadString('General', 'Name', '');
fHasArrows := ini.ReadBool('General', 'HasArrows', false);
fHasConveyors := ini.ReadBool('General', 'HasConveyors', false);
// T
{$IFDEF Client}
For i := 0 To 4 Do Begin
fPreviewLines[i] := ini.ReadString('Preview', 'Row' + inttostr(i + 1), '.....');
End;
{$ENDIF}
ini.free;
tmphash := MD5File(dir + 'info.txt');
AppendHash;
If name = '' Then exit; // Name ='' und Hash = 0 ist reserviert für das Random Field
If Not FileExists(dir + 'solid.png') Then exit;
{$IFDEF Client}
fSolidTex := OpenGL_GraphikEngine.LoadAlphaColorGraphik(dir + 'solid.png', ColorToRGB(clfuchsia), smStretchHard);
{$ENDIF}
tmphash := MD5File(dir + 'solid.png');
AppendHash;
fSoundFile := Dir + 'sound.wav';
If Not FileExists(fSoundFile) Then exit;
tmphash := MD5File(fSoundFile);
AppendHash;
If Not FileExists(dir + 'xbrick.ani') Then exit;
{$IFDEF Client}
xBrick := TOpenGL_Animation.Create;
xBrick.LoadFromFile(dir + 'xbrick.ani');
For i := 0 To FieldWidth - 1 Do
For j := 0 To FieldHeight - 1 Do Begin
fxBricks[i, j].ani := TOpenGL_Animation.Create;
fxBricks[i, j].ani.CloneFrom(xBrick);
fxBricks[i, j].ani.Tag := i + j * FieldWidth;
// TODO: Das Problem ist wenn der Server zu Langsam ist scheint das nicht zu gehen ...
fxBricks[i, j].ani.OnAnimationOverflowEvent := @OnxBrickOverflow;
fxBricks[i, j].Active := false;
End;
fxBrickAniTime := xBrick.Sprite[0].FrameCount * xBrick.Sprite[0].TimePerFrame;
xBrick.Free;
{$ENDIF}
tmphash := MD5File(dir + 'xbrick.ani');
AppendHash;
result := true;
End;
{$IFDEF Server}
Function TAtomicField.Detonate(x, y: integer; PlayerIndex, ColorIndex: integer;
Flame: TFlame): Boolean;
Var
i: Integer;
Begin
result := false;
If (x < 0) Or (y < 0) Or (x > FieldWidth - 1) Or (y > FieldHeight - 1) Then exit;
(*
* Durch Analyse von: https://www.youtube.com/watch?v=qOtCVIMFJu0 bei sec 0.37
* Flamen "überschreiben" sich gegenseitig
* Powerups verbrennen sofort ohne Flamme
*)
result := true;
Case fField[x, y].BrickData Of
bdBlank: Begin
If fField[x, y].PowerUp = puNone Then Begin
fField[x, y].FlameColor := ColorIndex;
fField[x, y].FlamePlayer := PlayerIndex;
If Not (fCross In fField[x, y].Flame) Then Begin // Sonst sieht es komisch aus ..
fField[x, y].Flame := [Flame];
End;
fField[x, y].Counter := 0;
End
Else Begin
fPowerUpClearFifo.Push(point(x, y));
// fField[x, y].PowerUp := puNone; -- Das geht net, da sonst 2 Bombem hintereinander durch das Popup durchschießen können !
result := false; // Egal wie der Strahl wird hier gestoppt !
End;
End;
bdBrick: Begin
If Not fField[x, y].Exploding Then Begin
StatisticCallback(sBricksDestroyed);
End;
fField[x, y].Exploding := true;
// fField[x, y].BrickData := bdBlank; // der darf nicht Gleich weg genommen werden, da sonst 2 Bomben auch 2 Steine auf einmal wegsprengen !
fField[x, y].Counter := 0;
result := False;
End;
bdSolid: result := false; // Ein Nicht zerstörbarer Brick, der ist einfach ;)
End;
// Auslösen von Kettenreaktionen
For i := 0 To fBombCount - 1 Do Begin
If Not fBombs[i].Detonated Then Begin
If (trunc(fBombs[i].Position.x) = x) And (trunc(fBombs[i].Position.y) = y) Then Begin
fBombDetonateFifo.push(i);
End;
End;
End;
End;
(*
* True, wenn man auf diese Koordinaten laufen kann
* es Kann belegt sein von einer Bombe und oder einem Stein
*)
Function TAtomicField.FielWalkable(x, y: integer; AlsoCheckPowerUps: Boolean
): Boolean;
Var
i: Integer;
Begin
result := false;
If (x < 0) Or (x > FieldWidth - 1) Or (y < 0) Or (y > FieldHeight - 1) Then exit;
result := fField[x, y].BrickData = bdBlank;
If Not result Then exit;
If AlsoCheckPowerUps Then Begin
result := fField[x, y].PowerUp = puNone;
End;
If Not result Then exit;
// Prüfung auf Bomben, reicht das so schon ?
For i := 0 To fBombCount - 1 Do Begin
If (x = trunc(fBombs[i].Position.x)) And
(y = trunc(fBombs[i].Position.y)) And
(fBombs[i].MoveDir <> bmFly) Then Begin
result := false;
exit;
End;
End;
End;
Procedure TAtomicField.Initialize(Const Players: TPlayers; Const Scheme: TScheme
);
Procedure SetBlank(x, y: integer);
Begin
If (x >= 0) And (x < FieldWidth) And (y >= 0) And (y < FieldHeight) Then Begin
fField[x, y].BrickData := bdBlank;
End;
End;
Var
i, j, maxpow: Integer;
Begin
{$IFDEF Server}
fBombCount := 0; // Sollte es je noch Bomben gegeben haben nu sind sie Platt ;)
fBombsEnabled := true;
fHurryIndex := -1;
{$ENDIF}
// Die Felder mit Elementen "Bevölkern"
// 1. Brick / Solid / Blank
For i := 0 To FieldWidth - 1 Do Begin
For j := 0 To FieldHeight - 1 Do Begin
fField[i, j].Exploding := false;
fField[i, j].Counter := 0;
fField[i, j].PowerUp := puNone;
fField[i, j].Flame := [];
fField[i, j].FlameColor := 0;
fField[i, j].FlamePlayer := -1;
Case Scheme.BrickData[i, j] Of
bdSolid: fField[i, j].BrickData := bdSolid;
bdBlank: fField[i, j].BrickData := bdBlank;
bdBrick: Begin
If Scheme.BrickDensity > random(100) Then Begin
fField[i, j].BrickData := bdBrick;
End
Else Begin
fField[i, j].BrickData := bdBlank;
End;
End;
End;
End;
End;
// 2. Die Spielerpositionen "Frei" Räumen
For i := 0 To high(Players) Do Begin
If Players[i].Info.Alive Then Begin
SetBlank(trunc(Players[i].Info.Position.x), trunc(Players[i].Info.Position.y));
SetBlank(trunc(Players[i].Info.Position.x) - 1, trunc(Players[i].Info.Position.y));
SetBlank(trunc(Players[i].Info.Position.x) + 1, trunc(Players[i].Info.Position.y));
SetBlank(trunc(Players[i].Info.Position.x), trunc(Players[i].Info.Position.y - 1));
SetBlank(trunc(Players[i].Info.Position.x), trunc(Players[i].Info.Position.y + 1));
End;
End;
// 3. Die PowerUps die Hinter den "Bricks" liegen
For i := 0 To FieldWidth - 1 Do Begin
For j := 0 To FieldHeight - 1 Do Begin
If fField[i, j].BrickData = bdBrick Then Begin // Nur Wo Wegsprengbare Steine sind, können Powerups drunder sein..
(* Die Random Powerups sind "Abschaltbar" *)
If Scheme.PowerUps[purandom].BornWith > 0 Then Begin
maxpow := 15;
End
Else Begin
maxpow := 14;
End;
Case random(maxpow) Of
0: fField[i, j].PowerUp := puNone;
1: fField[i, j].PowerUp := puExtraBomb;
2: fField[i, j].PowerUp := puLongerFlameLength;
3: fField[i, j].PowerUp := puDisease;
4: fField[i, j].PowerUp := puCanCick;
5: fField[i, j].PowerUp := puExtraSpeed;
6: fField[i, j].PowerUp := puCanPunch;
7: fField[i, j].PowerUp := puCanGrab;
8: fField[i, j].PowerUp := puCanSpooger;
9: fField[i, j].PowerUp := puGoldFlame;
10: fField[i, j].PowerUp := puTrigger;
11: fField[i, j].PowerUp := puCanJelly;
12: fField[i, j].PowerUp := puSuperBadDisease;
13: fField[i, j].PowerUp := puSlow;
14: fField[i, j].PowerUp := purandom;
End;
// TODO: das sollte ggf noch feiner Justiert werden ..
If fField[i, j].PowerUp <> puNone Then Begin
If Scheme.PowerUps[fField[i, j].PowerUp].Forbidden Then fField[i, j].PowerUp := puNone;
End;
End;
End;
End;
End;
Procedure TAtomicField.AppendGamingData(Const Stream: TStream);
Var
i: integer;
Begin
(*
* Da auf jedem Feld immer nur 1 Ding Gerendert werden kann ist das hier recht Easy ;)
*)
stream.Write(fField, SizeOf(fField));
{$IFDEF Server}
(*
* Wir Kopieren nur die Gültigen Bomben raus
*)
stream.Write(fBombCount, SizeOf(fBombCount));
For i := 0 To fBombCount - 1 Do Begin
stream.Write(fBombs[i].ColorIndex, SizeOf(fBombs[i].ColorIndex));
stream.Write(fBombs[i].Position, SizeOf(fBombs[i].Position));
stream.Write(fBombs[i].Animation, SizeOf(fBombs[i].Animation));
stream.Write(fBombs[i].AnimationOffset, SizeOf(fBombs[i].AnimationOffset));
End;
{$ENDIF}
End;
Function TAtomicField.HandleMovePlayer(Var Players: TPlayers; PlayerIndex: integer; ConveyorSpeed: TConveyorSpeed): Boolean;
Function GetBombIndex(x, y: integer): integer;
Var
i: Integer;
Begin
result := -1;
For i := 0 To fBombCount - 1 Do Begin
If (trunc(fBombs[i].Position.x) = x) And
(trunc(fBombs[i].Position.y) = y) And
(fBombs[i].MoveDir <> bmFly) Then Begin // Fliegende Bomben haben keine Kollisionen !
result := i;
exit;
End;
End;
End;
Const
Epsilon = 0.25; // Je Größer dieser Wert, desto mehr wird das Umlaufen der Ecken unterstützt (maximal wäre 0.5 möglich)
Var
dx, dy, cSpeed, commaparty, commapartx, rSpeed: Single;
dxi, dyi, nx, ny, x, y, index: Integer;
Begin
result := false;
// Die Kick Animation -> da bewegen wir uns erst mal nicht ;)
If (Players[PlayerIndex].Info.Animation = raKick) And (Players[PlayerIndex].Info.Counter < AtomicAnimationTimeKick - 2 * UpdateRate) Then exit; // A Bissle schneller wieder "Frei" geben als geplant
If (Players[PlayerIndex].Info.Animation = raPup) And (Players[PlayerIndex].Info.Counter < AtomicAnimationTimePup - 2 * UpdateRate) Then exit; // A Bissle schneller wieder "Frei" geben als geplant
(*
* Kickt der Spieler eine Bombe auf einem Laufband addieren sich die Geschwindigkeiten !
*)
cSpeed := 0;
If fHasConveyors And (Not Players[PlayerIndex].Flying) Then Begin
Case ConveyorSpeed Of
csSlow: cSpeed := ConveyorSlowSpeed / FrameRate; // So Umrechnen dass Speed = Kachel Pro Sekunde ist.
csMiddle: cSpeed := ConveyorMiddleSpeed / FrameRate; // So Umrechnen dass Speed = Kachel Pro Sekunde ist.
csFast: cSpeed := ConveyorFastSpeed / FrameRate; // So Umrechnen dass Speed = Kachel Pro Sekunde ist.
End;
x := trunc(Players[PlayerIndex].info.Position.x);
y := trunc(Players[PlayerIndex].info.Position.y);
commapartx := (Players[PlayerIndex].info.Position.x - trunc(Players[PlayerIndex].info.Position.x));
commaparty := (Players[PlayerIndex].info.Position.y - trunc(Players[PlayerIndex].info.Position.y));
// Die Bombe befindet sich "ungefähr" in der Mitte
dxi := 0;
dyi := 0;
Case fConveyorDirs[x, y] Of
0: dxi := 1;
90: dyi := -1;
180: dxi := -1;
270: dyi := 1;
End;
nx := x + dxi;
ny := y + dyi;
If Not FielWalkable(nx, ny, true) Then Begin
dxi := 0;
dyi := 0;
End;
Players[PlayerIndex].info.Position.x := Players[PlayerIndex].info.Position.x + dxi * cSpeed;
Players[PlayerIndex].info.Position.y := Players[PlayerIndex].info.Position.y + dyi * cSpeed;
// Reinziehen der Bomben auf Ordentliche Koordinaten !
If fConveyorDirs[x, y] <> -1 Then Begin // -- Aber nur wenn wir auch tatsächlich auf einem Laufband stehen..
If (commaparty <> 0.5) Then Begin
If (dxi <> 0) Then Begin
Players[PlayerIndex].info.Position.y := Players[PlayerIndex].info.Position.y + (0.5 - commaparty) * abs(commapartx - 0.5);
End
Else Begin
Players[PlayerIndex].info.Position.y := Players[PlayerIndex].info.Position.y + (0.5 - commaparty) * cSpeed;
End;
End;
If (commapartx <> 0.5) Then Begin
If (dyi <> 0) Then Begin
Players[PlayerIndex].info.Position.x := Players[PlayerIndex].info.Position.x + (0.5 - commapartx) * abs(commaparty - 0.5);
End
Else Begin
Players[PlayerIndex].info.Position.x := Players[PlayerIndex].info.Position.x + (0.5 - commapartx) * cSpeed;
End;
End;
End;
End;
cSpeed := 0;
rSpeed := Players[PlayerIndex].Powers.Speed / FrameRate; // So Umrechnen dass Speed = Kachel Pro Sekunde ist.
// Das Bewegen des Atomics anhand Seiner Daten
Case Players[PlayerIndex].MoveState Of
msStill: Players[PlayerIndex].Info.Animation := raStandStill;
msRight: Begin
Players[PlayerIndex].Info.Animation := raWalk;
Players[PlayerIndex].Info.Direction := 0;
Players[PlayerIndex].Info.Position.x := min(FieldWidth - 0.5, Players[PlayerIndex].Info.Position.x + rSpeed);
commapartx := (Players[PlayerIndex].Info.Position.x - trunc(Players[PlayerIndex].Info.Position.x));
commaparty := (Players[PlayerIndex].Info.Position.y - trunc(Players[PlayerIndex].Info.Position.y));
If commaparty <> 0.5 Then Begin
Players[PlayerIndex].Info.Position.y := Players[PlayerIndex].Info.Position.y + (0.5 - commaparty) * abs(commapartx - 0.5);
End;
// Schauen ob die kachel auf die wir Laufen wollen überhaupt "begehbar" ist
If commapartx > 0.5 Then Begin // Wir wollen Tatsächlich auf die Nächste Kachel Laufen
x := trunc(Players[PlayerIndex].Info.Position.x) + 1;
y := trunc(Players[PlayerIndex].info.Position.y);
If commaparty > 0.5 + Epsilon Then Begin
y := y + 1;
End;
If Not FielWalkable(x, y, false) Then Begin
index := GetBombIndex(x, y);
// Kann der Spieler Bomben Kicken ? und liegt da ne Bombe
If (Players[PlayerIndex].Powers.CanKickBombs) And (index <> -1) Then Begin
If FielWalkable(x + 1, y, true) Then Begin // Kann die Bombe sich bewegen ?
If fBombs[index].MoveDir <> bmRight Then Begin
fPlaySoundEffect(PlayerIndex, seBombKick);
Players[PlayerIndex].Info.Animation := raKick;
Players[PlayerIndex].Info.Counter := 0;
fBombs[index].MoveDir := bmRight;
fBombs[index].Jelly := Players[PlayerIndex].Powers.JellyBombs;
fBombs[index].Speed := Players[PlayerIndex].Powers.Speed + cSpeed;
End;
End
Else Begin
If fBombs[index].MoveDir <> bmNone Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.x := trunc(Players[PlayerIndex].Info.Position.x) + 0.5;
End;
End
Else Begin
If (index <> -1) And (fBombs[index].MoveDir <> bmNone) Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.x := trunc(Players[PlayerIndex].Info.Position.x) + 0.5;
End;
End;
End;
End;
msLeft: Begin
Players[PlayerIndex].Info.Animation := raWalk;
Players[PlayerIndex].Info.Direction := 180;
Players[PlayerIndex].Info.Position.x := max(0.5, Players[PlayerIndex].Info.Position.x - rSpeed);
commapartx := (Players[PlayerIndex].Info.Position.x - trunc(Players[PlayerIndex].Info.Position.x));
commaparty := (Players[PlayerIndex].Info.Position.y - trunc(Players[PlayerIndex].Info.Position.y));
If commaparty <> 0.5 Then Begin
Players[PlayerIndex].Info.Position.y := Players[PlayerIndex].Info.Position.y + (0.5 - commaparty) * abs(commapartx - 0.5);
End;
// Schauen ob die kachel auf die wir Laufen wollen überhaupt "begehbar" ist
If commapartx < 0.5 Then Begin // Wir wollen Tatsächlich auf die Nächste Kachel Laufen
x := trunc(Players[PlayerIndex].Info.Position.x) - 1;
y := trunc(Players[PlayerIndex].info.Position.y);
If commaparty > 0.5 + Epsilon Then Begin
y := y + 1;
End;
If Not FielWalkable(x, y, false) Then Begin
index := GetBombIndex(x, y);
// Kann der Spieler Bomben Kicken ? und liegt da ne Bombe
If (Players[PlayerIndex].Powers.CanKickBombs) And (index <> -1) Then Begin
If FielWalkable(x - 1, y, true) Then Begin // Kann die Bombe sich bewegen ?
If fBombs[index].MoveDir <> bmLeft Then Begin
fPlaySoundEffect(PlayerIndex, seBombKick);
Players[PlayerIndex].Info.Animation := raKick;
Players[PlayerIndex].Info.Counter := 0;
fBombs[index].MoveDir := bmLeft;
fBombs[index].Jelly := Players[PlayerIndex].Powers.JellyBombs;
fBombs[index].Speed := Players[PlayerIndex].Powers.Speed + cSpeed;
End;
End
Else Begin
If fBombs[index].MoveDir <> bmNone Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.x := trunc(Players[PlayerIndex].Info.Position.x) + 0.5;
End;
End
Else Begin
If (index <> -1) And (fBombs[index].MoveDir <> bmNone) Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.x := trunc(Players[PlayerIndex].Info.Position.x) + 0.5;
End;
End;
End;
End;
msUp: Begin
Players[PlayerIndex].Info.Animation := raWalk;
Players[PlayerIndex].Info.Direction := 90;
Players[PlayerIndex].Info.Position.y := max(0.5, Players[PlayerIndex].Info.Position.y - rSpeed);
commapartx := (Players[PlayerIndex].Info.Position.x - trunc(Players[PlayerIndex].Info.Position.x));
commaparty := (Players[PlayerIndex].Info.Position.y - trunc(Players[PlayerIndex].Info.Position.y));
If commapartx <> 0.5 Then Begin
Players[PlayerIndex].Info.Position.x := Players[PlayerIndex].Info.Position.x + (0.5 - commapartx) * abs(commaparty - 0.5);
End;
// Schauen ob die kachel auf die wir Laufen wollen überhaupt "begehbar" ist
If commaparty < 0.5 Then Begin // Wir wollen Tatsächlich auf die Nächste Kachel Laufen
x := trunc(Players[PlayerIndex].Info.Position.x);
y := trunc(Players[PlayerIndex].info.Position.y) - 1;
If commapartx > 0.5 + Epsilon Then Begin
x := x + 1;
End;
If Not FielWalkable(x, y, false) Then Begin
index := GetBombIndex(x, y);
// Kann der Spieler Bomben Kicken ? und liegt da ne Bombe
If (Players[PlayerIndex].Powers.CanKickBombs) And (index <> -1) Then Begin
If FielWalkable(x, y - 1, true) Then Begin // Kann die Bombe sich bewegen ?
If fBombs[index].MoveDir <> bmUp Then Begin
fPlaySoundEffect(PlayerIndex, seBombKick);
Players[PlayerIndex].Info.Animation := raKick;
Players[PlayerIndex].Info.Counter := 0;
fBombs[index].MoveDir := bmUp;
fBombs[index].Jelly := Players[PlayerIndex].Powers.JellyBombs;
fBombs[index].Speed := Players[PlayerIndex].Powers.Speed + cSpeed;
End;
End
Else Begin
If fBombs[index].MoveDir <> bmNone Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.y := trunc(Players[PlayerIndex].Info.Position.y) + 0.5;
End;
End
Else Begin
If (index <> -1) And (fBombs[index].MoveDir <> bmNone) Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.y := trunc(Players[PlayerIndex].Info.Position.y) + 0.5;
End;
End;
End;
End;
msDown: Begin
Players[PlayerIndex].Info.Animation := raWalk;
Players[PlayerIndex].Info.Direction := 270;
Players[PlayerIndex].Info.Position.y := min(FieldHeight - 0.5, Players[PlayerIndex].Info.Position.y + rSpeed);
commapartx := (Players[PlayerIndex].Info.Position.x - trunc(Players[PlayerIndex].Info.Position.x));
commaparty := (Players[PlayerIndex].Info.Position.y - trunc(Players[PlayerIndex].Info.Position.y));
If commapartx <> 0.5 Then Begin
Players[PlayerIndex].Info.Position.x := Players[PlayerIndex].Info.Position.x + (0.5 - commapartx) * abs(commaparty - 0.5);
End;
// Schauen ob die kachel auf die wir Laufen wollen überhaupt "begehbar" ist
If commaparty > 0.5 Then Begin // Wir wollen Tatsächlich auf die Nächste Kachel Laufen
x := trunc(Players[PlayerIndex].Info.Position.x);
y := trunc(Players[PlayerIndex].info.Position.y) + 1;
If commapartx > 0.5 + Epsilon Then Begin
x := x + 1;
End;
If Not FielWalkable(x, y, false) Then Begin
index := GetBombIndex(x, y);
// Kann der Spieler Bomben Kicken ? und liegt da ne Bombe
If (Players[PlayerIndex].Powers.CanKickBombs) And (index <> -1) Then Begin
If FielWalkable(x, y + 1, true) Then Begin // Kann die Bombe sich bewegen ?
If fBombs[index].MoveDir <> bmDown Then Begin
fPlaySoundEffect(PlayerIndex, seBombKick);
Players[PlayerIndex].Info.Animation := raKick;
Players[PlayerIndex].Info.Counter := 0;
fBombs[index].MoveDir := bmDown;
fBombs[index].Jelly := Players[PlayerIndex].Powers.JellyBombs;
fBombs[index].Speed := Players[PlayerIndex].Powers.Speed + cSpeed;
End;
End
Else Begin
If fBombs[index].MoveDir <> bmNone Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.y := trunc(Players[PlayerIndex].Info.Position.y) + 0.5;
End;
End
Else Begin
If (index <> -1) And (fBombs[index].MoveDir <> bmNone) Then Begin
fPlaySoundEffect(PlayerIndex, seBombStop);
fBombs[index].MoveDir := bmNone;
fBombs[index].Position.x := trunc(fBombs[index].Position.x) + 0.5;
fBombs[index].Position.y := trunc(fBombs[index].Position.y) + 0.5;
End;
Players[PlayerIndex].Info.Position.y := trunc(Players[PlayerIndex].Info.Position.y) + 0.5;
End;
End;
End;
End;
End;
// evtl. ist der Spieler ja "eingesperrt"
// TODO: Wenn die Spieler "Fliegen" muss das hier berücksichtigt werden
x := trunc(Players[PlayerIndex].Info.Position.x);
y := trunc(Players[PlayerIndex].info.Position.y);
If (Not FielWalkable(x - 1, y, false)) And
(Not FielWalkable(x + 1, y, false)) And
(Not FielWalkable(x, y - 1, false)) And
(Not FielWalkable(x, y + 1, false)) Then Begin
Players[PlayerIndex].info.Animation := raLockedIn;
Players[PlayerIndex].info.Value := random(65536);
End;
result := fField[x, y].BrickData = bdSolid;
End;
Procedure TAtomicField.HandleActionPlayer(Var Player: TPlayer;
PlayerIndex: integer);
Function PlaceBombOn(aX, aY: Single): Boolean;
Var
i: Integer;
Begin
result := false;
// Darf der Spieler überhaupt noch Bomben legen =
If player.Powers.AvailableBombs <= 0 Then exit;
// Liegt auf dem Feld schon eine Bombe ?