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; w
: Integer=1; h
: Integer=1): Boolean; inline;
107 result
:= g_Map_CollidePanel(x
, y
, w
, h
, (PANEL_WALL
or PANEL_CLOSEDOOR
or PANEL_STEP
));
112 function isWallAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
114 result
:= g_Map_CollidePanel(x
, y
, w
, h
, (PANEL_WALL
or PANEL_STEP
));
118 function isLiftUpAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
120 result
:= g_Map_CollidePanel(x
, y
, w
, h
, PANEL_LIFTUP
);
123 function isLiftDownAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
125 result
:= g_Map_CollidePanel(x
, y
, w
, h
, PANEL_LIFTDOWN
);
128 function isLiftLeftAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
130 result
:= g_Map_CollidePanel(x
, y
, w
, h
, PANEL_LIFTLEFT
);
133 function isLiftRightAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
135 result
:= g_Map_CollidePanel(x
, y
, w
, h
, PANEL_LIFTRIGHT
);
139 function isLiquidAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
141 result
:= g_Map_CollidePanel(x
, y
, w
, h
, (PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
145 function isAnythingAt (x
, y
: Integer; w
: Integer=1; h
: Integer=1): Boolean; inline;
147 result
:= g_Map_CollidePanel(x
, y
, w
, h
, (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 CurrentParticle
:= 0;
296 if OnceAnims
<> nil then
298 for a
:= 0 to High(OnceAnims
) do
299 OnceAnims
[a
].Animation
.Free();
306 procedure CorrectOffsets(id
: Integer);
310 part
:= @Particles
[id
];
313 // check for upper wall
314 if isBlockedAt(part
.X
, part
.Y
-1) then part
.offsetY
:= 1;
315 // check for left wall
316 if isBlockedAt(part
.X
-1, part
.Y
) then part
.offsetX
:= 1;
320 procedure g_GFX_SparkVel (fX
, fY
: Integer; Count
: Word; VX
, VY
: Integer; DevX
, DevY
: Byte);
327 l
:= Length(Particles
);
329 if Count
> l
then Count
:= l
;
336 for a
:= 1 to Count
do
338 with Particles
[CurrentParticle
] do
340 X
:= fX
-DevX1
+Random(DevX2
);
341 Y
:= fY
-DevY1
+Random(DevY2
);
343 VelX
:= VX
+ (Random
-Random
)*3;
344 VelY
:= VY
+ (Random
-Random
)*3;
352 AccelX
:= -Sign(VelX
)*Random
/100;
356 Green
:= 100+Random(155);
360 State
:= STATE_NORMAL
;
362 LiveTime
:= 30+Random(60);
363 ParticleType
:= PARTICLE_SPARK
;
365 CorrectOffsets(CurrentParticle
);
368 if CurrentParticle
+2 > MaxParticles
then
371 CurrentParticle
:= CurrentParticle
+1;
376 procedure g_GFX_Blood(fX
, fY
: Integer; Count
: Word; vx
, vy
: Integer;
377 DevX
, DevY
: Word; CR
, CG
, CB
: Byte; Kind
: Byte = BLOOD_NORMAL
);
386 if Kind
= BLOOD_SPARKS
then
388 g_GFX_SparkVel(fX
, fY
, 2 + Random(2), -VX
div 2, -VY
div 2, DevX
, DevY
);
391 l
:= Length(Particles
);
402 for a
:= 1 to Count
do
404 with Particles
[CurrentParticle
] do
406 X
:= fX
- DevX1
+ Random(DevX2
);
407 Y
:= fY
- DevY1
+ Random(DevY2
);
410 if (X < 0) or (X > gMapInfo.Width-1) or
411 (Y < 0) or (Y > gMapInfo.Height-1) or
412 ByteBool(gCollideMap[Y, X] and MARK_WALL) then
415 if isWallAt(X
, Y
) then continue
;
417 VelX
:= vx
+ (Random
-Random
)*3;
418 VelY
:= vy
+ (Random
-Random
)*3;
426 AccelX
:= -Sign(VelX
)*Random
/100;
429 CRnd
:= 20*Random(6);
432 CC
:= CR
+ CRnd
- 50;
433 if CC
< 0 then CC
:= 0;
434 if CC
> 255 then CC
:= 255;
440 CC
:= CG
+ CRnd
- 50;
441 if CC
< 0 then CC
:= 0;
442 if CC
> 255 then CC
:= 255;
448 CC
:= CB
+ CRnd
- 50;
449 if CC
< 0 then CC
:= 0;
450 if CC
> 255 then CC
:= 255;
457 State
:= STATE_NORMAL
;
459 LiveTime
:= 120+Random(40);
460 ParticleType
:= PARTICLE_BLOOD
;
462 CorrectOffsets(CurrentParticle
);
465 if CurrentParticle
>= MaxParticles
-1 then
468 CurrentParticle
:= CurrentParticle
+1;
473 procedure g_GFX_Spark(fX
, fY
: Integer; Count
: Word; Angle
: SmallInt; DevX
, DevY
: Byte);
479 BaseVelX
, BaseVelY
: Single;
482 l
:= Length(Particles
);
488 Angle
:= 360 - Angle
;
495 b
:= DegToRad(Angle
);
497 BaseVelY
:= 1.6*sin(b
);
498 if Abs(BaseVelX
) < 0.01 then
500 if Abs(BaseVelY
) < 0.01 then
502 for a
:= 1 to Count
do
504 with Particles
[CurrentParticle
] do
506 X
:= fX
-DevX1
+Random(DevX2
);
507 Y
:= fY
-DevY1
+Random(DevY2
);
509 VelX
:= BaseVelX
*Random
;
510 VelY
:= BaseVelY
-Random
;
515 Green
:= 100+Random(155);
519 State
:= STATE_NORMAL
;
521 LiveTime
:= 30+Random(60);
522 ParticleType
:= PARTICLE_SPARK
;
524 CorrectOffsets(CurrentParticle
);
527 if CurrentParticle
+2 > MaxParticles
then
530 CurrentParticle
:= CurrentParticle
+1;
534 procedure g_GFX_Water(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DevX
, DevY
, Color
: Byte);
541 l
:= Length(Particles
);
547 if Abs(fVelX
) < 3.0 then
548 fVelX
:= 3.0 - 6.0*Random
;
555 for a
:= 1 to Count
do
557 with Particles
[CurrentParticle
] do
559 X
:= fX
-DevX1
+Random(DevX2
);
560 Y
:= fY
-DevY1
+Random(DevY2
);
562 if Abs(fVelX
) < 0.5 then
563 VelX
:= 1.0 - 2.0*Random
565 VelX
:= fVelX
*Random
;
566 if Random(10) < 7 then
568 VelY
:= fVelY
*Random
;
575 Red
:= 155 + Random(9)*10;
576 Green
:= Trunc(150*Random
);
581 Red
:= Trunc(150*Random
);
582 Green
:= 175 + Random(9)*10;
587 Red
:= Trunc(200*Random
);
589 Blue
:= 175 + Random(9)*10;
593 Red
:= 90 + Random(12)*10;
601 State
:= STATE_NORMAL
;
603 LiveTime
:= 60+Random(60);
604 ParticleType
:= PARTICLE_WATER
;
606 CorrectOffsets(CurrentParticle
);
609 if CurrentParticle
+2 > MaxParticles
then
612 CurrentParticle
:= CurrentParticle
+1;
616 procedure g_GFX_SimpleWater(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DefColor
, CR
, CG
, CB
: Byte);
621 l
:= Length(Particles
);
627 for a
:= 1 to Count
do
629 with Particles
[CurrentParticle
] do
642 Red
:= 155 + Random(9)*10;
643 Green
:= Trunc(150*Random
);
648 Red
:= Trunc(150*Random
);
649 Green
:= 175 + Random(9)*10;
654 Red
:= Trunc(200*Random
);
656 Blue
:= 175 + Random(9)*10;
658 4: // Ñâîé öâåò, ñâåòëåå
660 Red
:= 20 + Random(19)*10;
663 Red
:= Min(Red
+ CR
, 255);
664 Green
:= Min(Green
+ CG
, 255);
665 Blue
:= Min(Blue
+ CB
, 255);
667 5: // Ñâîé öâåò, òåìíåå
669 Red
:= 20 + Random(19)*10;
672 Red
:= Max(CR
- Red
, 0);
673 Green
:= Max(CG
- Green
, 0);
674 Blue
:= Max(CB
- Blue
, 0);
678 Red
:= 90 + Random(12)*10;
686 State
:= STATE_NORMAL
;
688 LiveTime
:= 60+Random(60);
689 ParticleType
:= PARTICLE_WATER
;
691 CorrectOffsets(CurrentParticle
);
694 if CurrentParticle
+2 > MaxParticles
then
697 CurrentParticle
:= CurrentParticle
+1;
701 procedure g_GFX_Bubbles(fX
, fY
: Integer; Count
: Word; DevX
, DevY
: Byte);
708 l
:= Length(Particles
);
719 for a
:= 1 to Count
do
721 with Particles
[CurrentParticle
] do
723 X
:= fX
-DevX1
+Random(DevX2
);
724 Y
:= fY
-DevY1
+Random(DevY2
);
726 if (X
>= gMapInfo
.Width
) or (X
<= 0) or
727 (Y
>= gMapInfo
.Height
) or (Y
<= 0) then
730 if not isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
743 State
:= STATE_NORMAL
;
746 ParticleType
:= PARTICLE_BUBBLES
;
748 CorrectOffsets(CurrentParticle
);
751 if CurrentParticle
+2 > MaxParticles
then
754 CurrentParticle
:= CurrentParticle
+1;
758 procedure g_GFX_SetMax(Count
: Integer);
760 if Count
> 50000 then
763 SetLength(Particles
, Count
);
764 MaxParticles
:= Count
;
765 if CurrentParticle
>= Count
then
766 CurrentParticle
:= 0;
769 function g_GFX_GetMax(): Integer;
771 Result
:= MaxParticles
;
774 function FindOnceAnim
: DWORD
;
778 if OnceAnims
<> nil then
779 for i
:= 0 to High(OnceAnims
) do
780 if OnceAnims
[i
].Animation
= nil then
786 if OnceAnims
= nil then
788 SetLength(OnceAnims
, 16);
793 Result
:= High(OnceAnims
) + 1;
794 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
798 procedure g_GFX_OnceAnim(X
, Y
: Integer; Anim
: TAnimation
; AnimType
: Byte = 0);
805 find_id
:= FindOnceAnim();
807 OnceAnims
[find_id
].AnimType
:= AnimType
;
808 OnceAnims
[find_id
].Animation
:= TAnimation
.Create(Anim
.FramesID
, Anim
.Loop
, Anim
.Speed
);
809 OnceAnims
[find_id
].Animation
.Blending
:= Anim
.Blending
;
810 OnceAnims
[find_id
].Animation
.Alpha
:= Anim
.Alpha
;
811 OnceAnims
[find_id
].X
:= X
;
812 OnceAnims
[find_id
].Y
:= Y
;
815 procedure g_GFX_Update();
824 if Particles
<> nil then
827 h
:= gMapInfo
.Height
;
829 len
:= High(Particles
);
832 if Particles
[a
].State
<> 0 then
835 if Time
= LiveTime
then
837 if (X
+1 >= w
) or (Y
+1 >= h
) or (X
<= 0) or (Y
<= 0) then
839 if State
= STATE_FREE
then
847 if (State
= STATE_STICK
) then
849 if (not ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)) and
850 (not ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)) and
851 (not ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)) and
852 (not ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED))
855 if (not isBlockedAt(X
, Y
-1)) and
856 (not isBlockedAt(X
, Y
+1)) and
857 (not isBlockedAt(X
-1, Y
)) and
858 (not isBlockedAt(X
+1, Y
))
860 begin // Îòëèïëà - êàïàåò
863 State
:= STATE_NORMAL
;
866 if Random(200) = 100 then
867 begin // Ïðèëåïëåíà - íî âîçìîæíî ñòåêàåò
873 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
875 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
877 if VelY
> -4-Random(3) then
879 if Abs(VelX
) > 0.1 then
880 VelX
:= VelX
- VelX
/10.0;
881 VelX
:= VelX
+ (Random
-Random
)*0.2;
884 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
886 if VelX
> -8-Random(3) then
890 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
891 begin // Ïîòîê âïðàâî
892 if VelX
< 8+Random(3) then
901 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
902 if (State
<> STATE_STICK
) and
903 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
904 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
905 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
906 begin // Âèñèò â âîçäóõå - êàïàåò
909 State
:= STATE_NORMAL
;
923 if (X
+s
>= w
) or (X
+s
<= 0) then
929 //c := gCollideMap[Y, X+s];
931 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
937 State
:= STATE_STICK
;
956 if (Y
+s
>= h
) or (Y
+s
<= 0) then
962 //c := gCollideMap[Y+s, X];
964 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
970 if (s
> 0) and (State
<> STATE_STICK
) then
971 State
:= STATE_NORMAL
973 State
:= STATE_STICK
;
986 if (X
+dX
>= w
) or (Y
+dY
>= h
) or
987 (X
+dX
<= 0) or (Y
+dY
<= 0) or
988 isBlockedAt(X
+dX
, Y
+dY
) {ByteBool(gCollideMap[Y+dY, X+dX] and MARK_BLOCKED)} then
989 begin // Ñòåíà/äâåðü/ãðàíèöà
1001 VelX
:= VelX
+ AccelX
;
1002 VelY
:= VelY
+ AccelY
;
1004 // Êðîâü ðàñòâîðÿåòñÿ â æèäêîñòè:
1005 if isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
1009 Alpha
:= 255 - Trunc((255.0 * Time
) / LiveTime
);
1018 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) and
1019 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1020 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1021 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1022 begin // Âèñèò â âîçäóõå
1038 if (X
+s
>= w
) or (X
+s
<= 0) then
1040 State
:= STATE_FREE
;
1044 //c := gCollideMap[Y, X+s];
1046 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1047 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1053 if not isAnythingAt(X
+s
, Y
) {c = MARK_FREE} then
1057 State
:= STATE_FREE
;
1074 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1076 State
:= STATE_FREE
;
1080 //c := gCollideMap[Y+s, X];
1082 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1083 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1087 AccelY
:= Abs(AccelY
);
1089 else // Èëè íå ïàäàåò
1100 if not isAnythingAt(X
, Y
+s
) {c = MARK_FREE} then
1104 State
:= STATE_FREE
;
1111 VelX
:= VelX
+ AccelX
;
1115 AccelY
:= AccelY
+ 0.08;
1116 VelY
:= VelY
+ AccelY
;
1124 if (State
= STATE_STICK
) and (Random(30) = 15) then
1125 begin // Ñòåêàåò/îòëèïàåò
1128 if (not isBlockedAt(X
-1, Y
) {ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)}) and
1129 (not isBlockedAt(X
+1, Y
) {ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED)}) then
1130 State
:= STATE_NORMAL
;
1134 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
1136 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
1138 if VelY
> -4-Random(3) then
1140 if Abs(VelX
) > 0.1 then
1141 VelX
:= VelX
- VelX
/10.0;
1142 VelX
:= VelX
+ (Random
-Random
)*0.2;
1145 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
1146 begin // Ïîòîê âëåâî
1147 if VelX
> -8-Random(3) then
1151 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
1152 begin // Ïîòîê âïðàâî
1153 if VelX
< 8+Random(3) then
1162 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
1163 if (State
<> STATE_STICK
) and
1164 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1165 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1166 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1167 begin // Âèñèò â âîçäóõå - êàïàåò
1170 State
:= STATE_NORMAL
;
1180 for b
:= 1 to Abs(dX
) do
1182 if (X
+s
>= w
) or (X
+s
<= 0) then
1183 begin // Ñáîêó ãðàíèöà
1184 State
:= STATE_FREE
;
1188 //c := gCollideMap[Y, X+s];
1190 if isLiquidAt(X
+s
, Y
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1191 begin // Ñáîêó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1192 State
:= STATE_FREE
;
1196 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1197 begin // Ñòåíà/äâåðü
1202 State
:= STATE_STICK
;
1217 for b
:= 1 to Abs(dY
) do
1219 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1220 begin // Ñíèçó/ñâåðõó ãðàíèöà
1221 State
:= STATE_FREE
;
1225 //c := gCollideMap[Y+s, X];
1227 if isLiquidAt(X
, Y
+s
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1228 begin // Ñíèçó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1229 State
:= STATE_FREE
;
1233 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1234 begin // Ñòåíà/äâåðü
1239 if (s
> 0) and (State
<> STATE_STICK
) then
1240 State
:= STATE_NORMAL
1242 State
:= STATE_STICK
;
1250 VelX
:= VelX
+ AccelX
;
1251 VelY
:= VelY
+ AccelY
;
1267 for b
:= 1 to Abs(dY
) do
1269 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1271 State
:= STATE_FREE
;
1275 if not isLiquidAt(X
, Y
+s
) {ByteBool(gCollideMap[Y+s, X] and MARK_LIQUID)} then
1276 begin // Óæå íå æèäêîñòü
1277 State
:= STATE_FREE
;
1286 VelY
:= VelY
+ AccelY
;
1294 end; // Particles <> nil
1296 if OnceAnims
<> nil then
1298 for a
:= 0 to High(OnceAnims
) do
1299 if OnceAnims
[a
].Animation
<> nil then
1301 case OnceAnims
[a
].AnimType
of
1304 if Random(3) = 0 then
1305 OnceAnims
[a
].X
:= OnceAnims
[a
].X
-1+Random(3);
1306 if Random(2) = 0 then
1307 OnceAnims
[a
].Y
:= OnceAnims
[a
].Y
-Random(2);
1311 if OnceAnims
[a
].Animation
.Played
then
1313 OnceAnims
[a
].Animation
.Free();
1314 OnceAnims
[a
].Animation
:= nil;
1317 OnceAnims
[a
].Animation
.Update();
1322 procedure g_GFX_Draw();
1326 if Particles
<> nil then
1328 glDisable(GL_TEXTURE_2D
);
1332 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1336 len
:= High(Particles
);
1338 for a
:= 0 to len
do
1339 with Particles
[a
] do
1340 if (State
<> STATE_FREE
) and (X
>= sX
) and (Y
>= sY
) and
1341 (X
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
1343 glColor4ub(Red
, Green
, Blue
, Alpha
);
1344 glVertex2i(X
+ offsetX
, Y
+ offsetY
);
1349 glDisable(GL_BLEND
);
1352 if OnceAnims
<> nil then
1353 for a
:= 0 to High(OnceAnims
) do
1354 if OnceAnims
[a
].Animation
<> nil then
1355 with OnceAnims
[a
] do
1356 Animation
.Draw(X
, Y
, M_NONE
);