1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
38 MARK_BLOCKED
= MARK_WALL
+ MARK_DOOR
;
39 MARK_LIQUID
= MARK_WATER
+ MARK_ACID
;
40 MARK_LIFT
= MARK_LIFTDOWN
+ MARK_LIFTUP
+ MARK_LIFTLEFT
+ MARK_LIFTRIGHT
;
42 procedure g_GFX_Init();
43 procedure g_GFX_Free();
45 procedure g_GFX_Blood(fX
, fY
: Integer; Count
: Word; vx
, vy
: Integer;
46 DevX
, DevY
: Word; CR
, CG
, CB
: Byte; Kind
: Byte = BLOOD_NORMAL
);
47 procedure g_GFX_Spark(fX
, fY
: Integer; Count
: Word; Angle
: SmallInt; DevX
, DevY
: Byte);
48 procedure g_GFX_Water(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DevX
, DevY
, Color
: Byte);
49 procedure g_GFX_SimpleWater(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DefColor
, CR
, CG
, CB
: Byte);
50 procedure g_GFX_Bubbles(fX
, fY
: Integer; Count
: Word; DevX
, DevY
: Byte);
51 procedure g_GFX_SetMax(Count
: Integer);
52 function g_GFX_GetMax(): Integer;
54 procedure g_GFX_OnceAnim(X
, Y
: Integer; Anim
: TAnimation
; AnimType
: Byte = 0);
56 //procedure g_Mark(x, y, Width, Height: Integer; t: Byte; st: Boolean);
58 procedure g_GFX_Update();
59 procedure g_GFX_Draw();
65 g_map
, g_basic
, Math
, e_graphics
, GL
, GLExt
,
66 g_options
, g_console
, SysUtils
, g_triggers
, MAPDEF
,
67 g_game
, g_language
, g_net
;
70 PParticle
= ^TParticle
;
74 AccelX
, AccelY
: Single;
75 Red
, Green
, Blue
: Byte;
80 offsetX
, offsetY
: ShortInt;
86 Animation
: TAnimation
;
99 Particles
: array of TParticle
;
100 OnceAnims
: array of TOnceAnim
;
101 MaxParticles
: Integer;
102 CurrentParticle
: Integer;
105 function isBlockedAt (x
, y
: Integer): Boolean; inline;
107 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WALL
or PANEL_CLOSEDOOR
or PANEL_STEP
));
112 function isWallAt (x
, y
: Integer): Boolean; inline;
114 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WALL
or PANEL_STEP
));
118 function isLiftUpAt (x
, y
: Integer): Boolean; inline;
120 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTUP
);
123 function isLiftDownAt (x
, y
: Integer): Boolean; inline;
125 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTDOWN
);
128 function isLiftLeftAt (x
, y
: Integer): Boolean; inline;
130 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTLEFT
);
133 function isLiftRightAt (x
, y
: Integer): Boolean; inline;
135 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTRIGHT
);
139 function isLiquidAt (x
, y
: Integer): Boolean; inline;
141 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
145 function isAnythingAt (x
, y
: Integer): Boolean; inline;
147 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WALL
or PANEL_CLOSEDOOR
or PANEL_OPENDOOR
or PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
or PANEL_STEP
or PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
));
151 {$IF DEFINED(HAS_COLLIDE_BITMAP)}
152 procedure g_Mark(x
, y
, Width
, Height
: Integer; t
: Byte; st
: Boolean);
154 yy
, y2
, xx
, x2
: Integer;
167 Height
:= Height
+ y
;
174 if x
> gMapInfo
.Width
then
176 if y
> gMapInfo
.Height
then
179 y2
:= y
+ Height
- 1;
180 if y2
> gMapInfo
.Height
then
181 y2
:= gMapInfo
.Height
;
184 if x2
> gMapInfo
.Width
then
185 x2
:= gMapInfo
.Width
;
188 begin // Óñòàíîâèòü ïðèçíàê
191 gCollideMap
[yy
][xx
] := gCollideMap
[yy
][xx
] or t
;
194 begin // Óáðàòü ïðèçíàê
198 gCollideMap
[yy
][xx
] := gCollideMap
[yy
][xx
] and t
;
204 {$IF DEFINED(HAS_COLLIDE_BITMAP)}
205 procedure CreateCollideMap();
209 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 1/6', 0, False);
210 SetLength(gCollideMap
, gMapInfo
.Height
+1);
211 for a
:= 0 to High(gCollideMap
) do
212 SetLength(gCollideMap
[a
], gMapInfo
.Width
+1);
214 if gWater
<> nil then
216 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 2/6', 0, True);
217 for a
:= 0 to High(gWater
) do
219 g_Mark(X
, Y
, Width
, Height
, MARK_WATER
, True);
222 if gAcid1
<> nil then
224 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 3/6', 0, True);
225 for a
:= 0 to High(gAcid1
) do
227 g_Mark(X
, Y
, Width
, Height
, MARK_ACID
, True);
230 if gAcid2
<> nil then
232 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 4/6', 0, True);
233 for a
:= 0 to High(gAcid2
) do
235 g_Mark(X
, Y
, Width
, Height
, MARK_ACID
, True);
238 if gLifts
<> nil then
240 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 5/6', 0, True);
241 for a
:= 0 to High(gLifts
) do
244 g_Mark(X
, Y
, Width
, Height
, MARK_LIFT
, False);
247 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTUP
, True)
248 else if LiftType
= 1 then
249 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTDOWN
, True)
250 else if LiftType
= 2 then
251 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTLEFT
, True)
252 else if LiftType
= 3 then
253 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTRIGHT
, True)
257 if gWalls
<> nil then
259 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 6/6', 0, True);
260 for a
:= 0 to High(gWalls
) do
262 if gWalls
[a
].Door
then
265 if gWalls
[a
].Enabled
then
267 g_Mark(X
, Y
, Width
, Height
, MARK_DOOR
, True)
268 else // Îòêðûòàÿ äâåðü:
269 if gWalls
[a
].Enabled
then
271 g_Mark(X
, Y
, Width
, Height
, MARK_DOOR
, False);
275 g_Mark(X
, Y
, Width
, Height
, MARK_WALL
, True);
282 procedure g_GFX_Init();
284 //CreateCollideMap();
288 procedure g_GFX_Free();
293 SetLength(Particles
, MaxParticles
);
294 for a
:= 0 to High(Particles
) do Particles
[a
].State
:= STATE_FREE
;
295 CurrentParticle
:= 0;
297 if OnceAnims
<> nil then
299 for a
:= 0 to High(OnceAnims
) do
300 OnceAnims
[a
].Animation
.Free();
307 procedure CorrectOffsets(id
: Integer);
311 part
:= @Particles
[id
];
314 // check for upper wall
315 if isBlockedAt(part
.X
, part
.Y
-1) then part
.offsetY
:= 1;
316 // check for left wall
317 if isBlockedAt(part
.X
-1, part
.Y
) then part
.offsetX
:= 1;
321 procedure g_GFX_SparkVel (fX
, fY
: Integer; Count
: Word; VX
, VY
: Integer; DevX
, DevY
: Byte);
328 l
:= Length(Particles
);
330 if Count
> l
then Count
:= l
;
337 for a
:= 1 to Count
do
339 with Particles
[CurrentParticle
] do
341 X
:= fX
-DevX1
+Random(DevX2
);
342 Y
:= fY
-DevY1
+Random(DevY2
);
344 VelX
:= VX
+ (Random
-Random
)*3;
345 VelY
:= VY
+ (Random
-Random
)*3;
353 AccelX
:= -Sign(VelX
)*Random
/100;
357 Green
:= 100+Random(155);
361 State
:= STATE_NORMAL
;
363 LiveTime
:= 30+Random(60);
364 ParticleType
:= PARTICLE_SPARK
;
366 CorrectOffsets(CurrentParticle
);
369 if CurrentParticle
+2 > MaxParticles
then
372 CurrentParticle
:= CurrentParticle
+1;
377 procedure g_GFX_Blood(fX
, fY
: Integer; Count
: Word; vx
, vy
: Integer;
378 DevX
, DevY
: Word; CR
, CG
, CB
: Byte; Kind
: Byte = BLOOD_NORMAL
);
387 if Kind
= BLOOD_SPARKS
then
389 g_GFX_SparkVel(fX
, fY
, 2 + Random(2), -VX
div 2, -VY
div 2, DevX
, DevY
);
392 l
:= Length(Particles
);
403 for a
:= 1 to Count
do
405 with Particles
[CurrentParticle
] do
407 X
:= fX
- DevX1
+ Random(DevX2
);
408 Y
:= fY
- DevY1
+ Random(DevY2
);
411 if (X < 0) or (X > gMapInfo.Width-1) or
412 (Y < 0) or (Y > gMapInfo.Height-1) or
413 ByteBool(gCollideMap[Y, X] and MARK_WALL) then
416 if isWallAt(X
, Y
) then continue
;
418 VelX
:= vx
+ (Random
-Random
)*3;
419 VelY
:= vy
+ (Random
-Random
)*3;
427 AccelX
:= -Sign(VelX
)*Random
/100;
430 CRnd
:= 20*Random(6);
433 CC
:= CR
+ CRnd
- 50;
434 if CC
< 0 then CC
:= 0;
435 if CC
> 255 then CC
:= 255;
441 CC
:= CG
+ CRnd
- 50;
442 if CC
< 0 then CC
:= 0;
443 if CC
> 255 then CC
:= 255;
449 CC
:= CB
+ CRnd
- 50;
450 if CC
< 0 then CC
:= 0;
451 if CC
> 255 then CC
:= 255;
458 State
:= STATE_NORMAL
;
460 LiveTime
:= 120+Random(40);
461 ParticleType
:= PARTICLE_BLOOD
;
463 CorrectOffsets(CurrentParticle
);
466 if CurrentParticle
>= MaxParticles
-1 then
469 CurrentParticle
:= CurrentParticle
+1;
474 procedure g_GFX_Spark(fX
, fY
: Integer; Count
: Word; Angle
: SmallInt; DevX
, DevY
: Byte);
480 BaseVelX
, BaseVelY
: Single;
483 l
:= Length(Particles
);
489 Angle
:= 360 - Angle
;
496 b
:= DegToRad(Angle
);
498 BaseVelY
:= 1.6*sin(b
);
499 if Abs(BaseVelX
) < 0.01 then
501 if Abs(BaseVelY
) < 0.01 then
503 for a
:= 1 to Count
do
505 with Particles
[CurrentParticle
] do
507 X
:= fX
-DevX1
+Random(DevX2
);
508 Y
:= fY
-DevY1
+Random(DevY2
);
510 VelX
:= BaseVelX
*Random
;
511 VelY
:= BaseVelY
-Random
;
516 Green
:= 100+Random(155);
520 State
:= STATE_NORMAL
;
522 LiveTime
:= 30+Random(60);
523 ParticleType
:= PARTICLE_SPARK
;
525 CorrectOffsets(CurrentParticle
);
528 if CurrentParticle
+2 > MaxParticles
then
531 CurrentParticle
:= CurrentParticle
+1;
535 procedure g_GFX_Water(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DevX
, DevY
, Color
: Byte);
542 l
:= Length(Particles
);
548 if Abs(fVelX
) < 3.0 then
549 fVelX
:= 3.0 - 6.0*Random
;
556 for a
:= 1 to Count
do
558 with Particles
[CurrentParticle
] do
560 X
:= fX
-DevX1
+Random(DevX2
);
561 Y
:= fY
-DevY1
+Random(DevY2
);
563 if Abs(fVelX
) < 0.5 then
564 VelX
:= 1.0 - 2.0*Random
566 VelX
:= fVelX
*Random
;
567 if Random(10) < 7 then
569 VelY
:= fVelY
*Random
;
576 Red
:= 155 + Random(9)*10;
577 Green
:= Trunc(150*Random
);
582 Red
:= Trunc(150*Random
);
583 Green
:= 175 + Random(9)*10;
588 Red
:= Trunc(200*Random
);
590 Blue
:= 175 + Random(9)*10;
594 Red
:= 90 + Random(12)*10;
602 State
:= STATE_NORMAL
;
604 LiveTime
:= 60+Random(60);
605 ParticleType
:= PARTICLE_WATER
;
607 CorrectOffsets(CurrentParticle
);
610 if CurrentParticle
+2 > MaxParticles
then
613 CurrentParticle
:= CurrentParticle
+1;
617 procedure g_GFX_SimpleWater(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DefColor
, CR
, CG
, CB
: Byte);
622 l
:= Length(Particles
);
628 for a
:= 1 to Count
do
630 with Particles
[CurrentParticle
] do
643 Red
:= 155 + Random(9)*10;
644 Green
:= Trunc(150*Random
);
649 Red
:= Trunc(150*Random
);
650 Green
:= 175 + Random(9)*10;
655 Red
:= Trunc(200*Random
);
657 Blue
:= 175 + Random(9)*10;
659 4: // Ñâîé öâåò, ñâåòëåå
661 Red
:= 20 + Random(19)*10;
664 Red
:= Min(Red
+ CR
, 255);
665 Green
:= Min(Green
+ CG
, 255);
666 Blue
:= Min(Blue
+ CB
, 255);
668 5: // Ñâîé öâåò, òåìíåå
670 Red
:= 20 + Random(19)*10;
673 Red
:= Max(CR
- Red
, 0);
674 Green
:= Max(CG
- Green
, 0);
675 Blue
:= Max(CB
- Blue
, 0);
679 Red
:= 90 + Random(12)*10;
687 State
:= STATE_NORMAL
;
689 LiveTime
:= 60+Random(60);
690 ParticleType
:= PARTICLE_WATER
;
692 CorrectOffsets(CurrentParticle
);
695 if CurrentParticle
+2 > MaxParticles
then
698 CurrentParticle
:= CurrentParticle
+1;
702 procedure g_GFX_Bubbles(fX
, fY
: Integer; Count
: Word; DevX
, DevY
: Byte);
709 l
:= Length(Particles
);
720 for a
:= 1 to Count
do
722 with Particles
[CurrentParticle
] do
724 X
:= fX
-DevX1
+Random(DevX2
);
725 Y
:= fY
-DevY1
+Random(DevY2
);
727 if (X
>= gMapInfo
.Width
) or (X
<= 0) or
728 (Y
>= gMapInfo
.Height
) or (Y
<= 0) then
731 if not isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
744 State
:= STATE_NORMAL
;
747 ParticleType
:= PARTICLE_BUBBLES
;
749 CorrectOffsets(CurrentParticle
);
752 if CurrentParticle
+2 > MaxParticles
then
755 CurrentParticle
:= CurrentParticle
+1;
759 procedure g_GFX_SetMax(Count
: Integer);
763 if Count
> 50000 then Count
:= 50000;
764 if (Count
< 1) then Count
:= 1;
766 SetLength(Particles
, Count
);
767 for a
:= 0 to High(Particles
) do Particles
[a
].State
:= STATE_FREE
;
768 MaxParticles
:= Count
;
769 //if CurrentParticle >= Count then
770 CurrentParticle
:= 0;
773 function g_GFX_GetMax(): Integer;
775 Result
:= MaxParticles
;
778 function FindOnceAnim
: DWORD
;
782 if OnceAnims
<> nil then
783 for i
:= 0 to High(OnceAnims
) do
784 if OnceAnims
[i
].Animation
= nil then
790 if OnceAnims
= nil then
792 SetLength(OnceAnims
, 16);
797 Result
:= High(OnceAnims
) + 1;
798 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
802 procedure g_GFX_OnceAnim(X
, Y
: Integer; Anim
: TAnimation
; AnimType
: Byte = 0);
809 find_id
:= FindOnceAnim();
811 OnceAnims
[find_id
].AnimType
:= AnimType
;
812 OnceAnims
[find_id
].Animation
:= TAnimation
.Create(Anim
.FramesID
, Anim
.Loop
, Anim
.Speed
);
813 OnceAnims
[find_id
].Animation
.Blending
:= Anim
.Blending
;
814 OnceAnims
[find_id
].Animation
.Alpha
:= Anim
.Alpha
;
815 OnceAnims
[find_id
].X
:= X
;
816 OnceAnims
[find_id
].Y
:= Y
;
819 procedure g_GFX_Update();
828 if Particles
<> nil then
831 h
:= gMapInfo
.Height
;
833 len
:= High(Particles
);
837 if Particles
[a
].State
<> STATE_FREE
then
841 if Time
= LiveTime
then State
:= STATE_FREE
;
842 if (X
+1 >= w
) or (Y
+1 >= h
) or (X
<= 0) or (Y
<= 0) then State
:= STATE_FREE
;
843 if State
= STATE_FREE
then Continue
;
844 //e_WriteLog(Format('particle #%d: %d', [State, ParticleType]), MSG_NOTIFY);
851 if (State
= STATE_STICK
) then
853 if (not ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)) and
854 (not ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)) and
855 (not ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)) and
856 (not ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED))
859 if (not isBlockedAt(X
, Y
-1)) and
860 (not isBlockedAt(X
, Y
+1)) and
861 (not isBlockedAt(X
-1, Y
)) and
862 (not isBlockedAt(X
+1, Y
))
864 begin // Îòëèïëà - êàïàåò
867 State
:= STATE_NORMAL
;
870 if Random(200) = 100 then
871 begin // Ïðèëåïëåíà - íî âîçìîæíî ñòåêàåò
877 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
879 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
881 if VelY
> -4-Random(3) then
883 if Abs(VelX
) > 0.1 then
884 VelX
:= VelX
- VelX
/10.0;
885 VelX
:= VelX
+ (Random
-Random
)*0.2;
888 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
890 if VelX
> -8-Random(3) then
894 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
895 begin // Ïîòîê âïðàâî
896 if VelX
< 8+Random(3) then
905 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
906 if (State
<> STATE_STICK
) and
907 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
908 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
909 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
910 begin // Âèñèò â âîçäóõå - êàïàåò
913 State
:= STATE_NORMAL
;
927 if (X
+s
>= w
) or (X
+s
<= 0) then
933 //c := gCollideMap[Y, X+s];
935 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
941 State
:= STATE_STICK
;
960 if (Y
+s
>= h
) or (Y
+s
<= 0) then
966 //c := gCollideMap[Y+s, X];
968 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
974 if (s
> 0) and (State
<> STATE_STICK
) then
975 State
:= STATE_NORMAL
977 State
:= STATE_STICK
;
990 if (X
+dX
>= w
) or (Y
+dY
>= h
) or
991 (X
+dX
<= 0) or (Y
+dY
<= 0) or
992 isBlockedAt(X
+dX
, Y
+dY
) {ByteBool(gCollideMap[Y+dY, X+dX] and MARK_BLOCKED)} then
993 begin // Ñòåíà/äâåðü/ãðàíèöà
1005 VelX
:= VelX
+ AccelX
;
1006 VelY
:= VelY
+ AccelY
;
1008 // Êðîâü ðàñòâîðÿåòñÿ â æèäêîñòè:
1009 if isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
1013 Alpha
:= 255 - Trunc((255.0 * Time
) / LiveTime
);
1022 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) and
1023 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1024 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1025 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1026 begin // Âèñèò â âîçäóõå
1042 if (X
+s
>= w
) or (X
+s
<= 0) then
1044 State
:= STATE_FREE
;
1048 //c := gCollideMap[Y, X+s];
1050 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1051 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1057 if not isAnythingAt(X
+s
, Y
) {c = MARK_FREE} then
1061 State
:= STATE_FREE
;
1078 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1080 State
:= STATE_FREE
;
1084 //c := gCollideMap[Y+s, X];
1086 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1087 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1091 AccelY
:= Abs(AccelY
);
1093 else // Èëè íå ïàäàåò
1104 if not isAnythingAt(X
, Y
+s
) {c = MARK_FREE} then
1108 State
:= STATE_FREE
;
1115 VelX
:= VelX
+ AccelX
;
1119 AccelY
:= AccelY
+ 0.08;
1120 VelY
:= VelY
+ AccelY
;
1128 if (State
= STATE_STICK
) and (Random(30) = 15) then
1129 begin // Ñòåêàåò/îòëèïàåò
1132 if (not isBlockedAt(X
-1, Y
) {ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)}) and
1133 (not isBlockedAt(X
+1, Y
) {ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED)}) then
1134 State
:= STATE_NORMAL
;
1138 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
1140 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
1142 if VelY
> -4-Random(3) then
1144 if Abs(VelX
) > 0.1 then
1145 VelX
:= VelX
- VelX
/10.0;
1146 VelX
:= VelX
+ (Random
-Random
)*0.2;
1149 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
1150 begin // Ïîòîê âëåâî
1151 if VelX
> -8-Random(3) then
1155 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
1156 begin // Ïîòîê âïðàâî
1157 if VelX
< 8+Random(3) then
1166 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
1167 if (State
<> STATE_STICK
) and
1168 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1169 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1170 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1171 begin // Âèñèò â âîçäóõå - êàïàåò
1174 State
:= STATE_NORMAL
;
1184 for b
:= 1 to Abs(dX
) do
1186 if (X
+s
>= w
) or (X
+s
<= 0) then
1187 begin // Ñáîêó ãðàíèöà
1188 State
:= STATE_FREE
;
1192 //c := gCollideMap[Y, X+s];
1194 if isLiquidAt(X
+s
, Y
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1195 begin // Ñáîêó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1196 State
:= STATE_FREE
;
1200 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1201 begin // Ñòåíà/äâåðü
1206 State
:= STATE_STICK
;
1221 for b
:= 1 to Abs(dY
) do
1223 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1224 begin // Ñíèçó/ñâåðõó ãðàíèöà
1225 State
:= STATE_FREE
;
1229 //c := gCollideMap[Y+s, X];
1231 if isLiquidAt(X
, Y
+s
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1232 begin // Ñíèçó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1233 State
:= STATE_FREE
;
1237 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1238 begin // Ñòåíà/äâåðü
1243 if (s
> 0) and (State
<> STATE_STICK
) then
1244 State
:= STATE_NORMAL
1246 State
:= STATE_STICK
;
1254 VelX
:= VelX
+ AccelX
;
1255 VelY
:= VelY
+ AccelY
;
1271 for b
:= 1 to Abs(dY
) do
1273 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1275 State
:= STATE_FREE
;
1279 if not isLiquidAt(X
, Y
+s
) {ByteBool(gCollideMap[Y+s, X] and MARK_LIQUID)} then
1280 begin // Óæå íå æèäêîñòü
1281 State
:= STATE_FREE
;
1290 VelY
:= VelY
+ AccelY
;
1300 end; // Particles <> nil
1302 if OnceAnims
<> nil then
1304 for a
:= 0 to High(OnceAnims
) do
1305 if OnceAnims
[a
].Animation
<> nil then
1307 case OnceAnims
[a
].AnimType
of
1310 if Random(3) = 0 then
1311 OnceAnims
[a
].X
:= OnceAnims
[a
].X
-1+Random(3);
1312 if Random(2) = 0 then
1313 OnceAnims
[a
].Y
:= OnceAnims
[a
].Y
-Random(2);
1317 if OnceAnims
[a
].Animation
.Played
then
1319 OnceAnims
[a
].Animation
.Free();
1320 OnceAnims
[a
].Animation
:= nil;
1323 OnceAnims
[a
].Animation
.Update();
1328 procedure g_GFX_Draw();
1332 if Particles
<> nil then
1334 glDisable(GL_TEXTURE_2D
);
1338 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1342 len
:= High(Particles
);
1344 for a
:= 0 to len
do
1345 with Particles
[a
] do
1346 if (State
<> STATE_FREE
) and (X
>= sX
) and (Y
>= sY
) and
1347 (X
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
1349 glColor4ub(Red
, Green
, Blue
, Alpha
);
1350 glVertex2i(X
+ offsetX
, Y
+ offsetY
);
1355 glDisable(GL_BLEND
);
1358 if OnceAnims
<> nil then
1359 for a
:= 0 to High(OnceAnims
) do
1360 if OnceAnims
[a
].Animation
<> nil then
1361 with OnceAnims
[a
] do
1362 Animation
.Draw(X
, Y
, M_NONE
);