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();
63 gpart_dbg_enabled
: Boolean = true;
64 gpart_dbg_phys_enabled
: Boolean = true;
70 g_map
, g_basic
, Math
, e_graphics
, GL
, GLExt
,
71 g_options
, g_console
, SysUtils
, g_triggers
, MAPDEF
,
72 g_game
, g_language
, g_net
;
75 PParticle
= ^TParticle
;
79 AccelX
, AccelY
: Single;
80 Red
, Green
, Blue
: Byte;
85 offsetX
, offsetY
: ShortInt;
91 Animation
: TAnimation
;
104 Particles
: array of TParticle
;
105 OnceAnims
: array of TOnceAnim
;
106 MaxParticles
: Integer;
107 CurrentParticle
: Integer;
110 function isBlockedAt (x
, y
: Integer): Boolean; inline;
112 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
113 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WALL
or PANEL_CLOSEDOOR
or PANEL_STEP
));
117 function isWallAt (x
, y
: Integer): Boolean; inline;
119 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
120 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WALL
or PANEL_STEP
));
123 function isLiftUpAt (x
, y
: Integer): Boolean; inline;
125 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
126 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTUP
);
129 function isLiftDownAt (x
, y
: Integer): Boolean; inline;
131 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
132 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTDOWN
);
135 function isLiftLeftAt (x
, y
: Integer): Boolean; inline;
137 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
138 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTLEFT
);
141 function isLiftRightAt (x
, y
: Integer): Boolean; inline;
143 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
144 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, PANEL_LIFTRIGHT
);
147 function isLiquidAt (x
, y
: Integer): Boolean; inline;
149 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
150 result
:= g_Map_HasAnyPanelAtPoint(x
, y
, (PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
153 function isAnythingAt (x
, y
: Integer): Boolean; inline;
155 if not gpart_dbg_phys_enabled
then begin result
:= false; exit
; end;
156 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
));
160 procedure g_Mark(x
, y
, Width
, Height
: Integer; t
: Byte; st
: Boolean);
161 {$IF not DEFINED(HAS_COLLIDE_BITMAP)}
166 yy
, y2
, xx
, x2
: Integer;
179 Height
:= Height
+ y
;
186 if x
> gMapInfo
.Width
then
188 if y
> gMapInfo
.Height
then
191 y2
:= y
+ Height
- 1;
192 if y2
> gMapInfo
.Height
then
193 y2
:= gMapInfo
.Height
;
196 if x2
> gMapInfo
.Width
then
197 x2
:= gMapInfo
.Width
;
200 begin // Óñòàíîâèòü ïðèçíàê
203 gCollideMap
[yy
][xx
] := gCollideMap
[yy
][xx
] or t
;
206 begin // Óáðàòü ïðèçíàê
210 gCollideMap
[yy
][xx
] := gCollideMap
[yy
][xx
] and t
;
216 {$IF DEFINED(HAS_COLLIDE_BITMAP)}
217 procedure CreateCollideMap();
221 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 1/6', 0, False);
222 SetLength(gCollideMap
, gMapInfo
.Height
+1);
223 for a
:= 0 to High(gCollideMap
) do
224 SetLength(gCollideMap
[a
], gMapInfo
.Width
+1);
226 if gWater
<> nil then
228 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 2/6', 0, True);
229 for a
:= 0 to High(gWater
) do
231 g_Mark(X
, Y
, Width
, Height
, MARK_WATER
, True);
234 if gAcid1
<> nil then
236 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 3/6', 0, True);
237 for a
:= 0 to High(gAcid1
) do
239 g_Mark(X
, Y
, Width
, Height
, MARK_ACID
, True);
242 if gAcid2
<> nil then
244 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 4/6', 0, True);
245 for a
:= 0 to High(gAcid2
) do
247 g_Mark(X
, Y
, Width
, Height
, MARK_ACID
, True);
250 if gLifts
<> nil then
252 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 5/6', 0, True);
253 for a
:= 0 to High(gLifts
) do
256 g_Mark(X
, Y
, Width
, Height
, MARK_LIFT
, False);
259 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTUP
, True)
260 else if LiftType
= 1 then
261 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTDOWN
, True)
262 else if LiftType
= 2 then
263 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTLEFT
, True)
264 else if LiftType
= 3 then
265 g_Mark(X
, Y
, Width
, Height
, MARK_LIFTRIGHT
, True)
269 if gWalls
<> nil then
271 g_Game_SetLoadingText(_lc
[I_LOAD_COLLIDE_MAP
]+' 6/6', 0, True);
272 for a
:= 0 to High(gWalls
) do
274 if gWalls
[a
].Door
then
277 if gWalls
[a
].Enabled
then
279 g_Mark(X
, Y
, Width
, Height
, MARK_DOOR
, True)
280 else // Îòêðûòàÿ äâåðü:
281 if gWalls
[a
].Enabled
then
283 g_Mark(X
, Y
, Width
, Height
, MARK_DOOR
, False);
287 g_Mark(X
, Y
, Width
, Height
, MARK_WALL
, True);
294 procedure g_GFX_Init();
296 //CreateCollideMap();
300 procedure g_GFX_Free();
305 SetLength(Particles
, MaxParticles
);
306 for a
:= 0 to High(Particles
) do Particles
[a
].State
:= STATE_FREE
;
307 CurrentParticle
:= 0;
309 if OnceAnims
<> nil then
311 for a
:= 0 to High(OnceAnims
) do
312 OnceAnims
[a
].Animation
.Free();
320 procedure CorrectOffsets(id: Integer); inline;
324 part := @Particles[id];
327 // check for upper wall
328 if isBlockedAt(part.X, part.Y-1) then part.offsetY := 1;
329 // check for left wall
330 if isBlockedAt(part.X-1, part.Y) then part.offsetX := 1;
335 procedure g_GFX_SparkVel (fX
, fY
: Integer; Count
: Word; VX
, VY
: Integer; DevX
, DevY
: Byte);
342 l
:= Length(Particles
);
344 if Count
> l
then Count
:= l
;
351 for a
:= 1 to Count
do
353 with Particles
[CurrentParticle
] do
355 X
:= fX
-DevX1
+Random(DevX2
);
356 Y
:= fY
-DevY1
+Random(DevY2
);
358 VelX
:= VX
+ (Random
-Random
)*3;
359 VelY
:= VY
+ (Random
-Random
)*3;
367 AccelX
:= -Sign(VelX
)*Random
/100;
371 Green
:= 100+Random(155);
375 State
:= STATE_NORMAL
;
377 LiveTime
:= 30+Random(60);
378 ParticleType
:= PARTICLE_SPARK
;
380 {CorrectOffsets(CurrentParticle);}
383 if CurrentParticle
+2 > MaxParticles
then
386 CurrentParticle
:= CurrentParticle
+1;
391 procedure g_GFX_Blood(fX
, fY
: Integer; Count
: Word; vx
, vy
: Integer;
392 DevX
, DevY
: Word; CR
, CG
, CB
: Byte; Kind
: Byte = BLOOD_NORMAL
);
401 if Kind
= BLOOD_SPARKS
then
403 g_GFX_SparkVel(fX
, fY
, 2 + Random(2), -VX
div 2, -VY
div 2, DevX
, DevY
);
406 l
:= Length(Particles
);
417 for a
:= 1 to Count
do
419 with Particles
[CurrentParticle
] do
421 X
:= fX
- DevX1
+ Random(DevX2
);
422 Y
:= fY
- DevY1
+ Random(DevY2
);
425 if (X < 0) or (X > gMapInfo.Width-1) or
426 (Y < 0) or (Y > gMapInfo.Height-1) or
427 ByteBool(gCollideMap[Y, X] and MARK_WALL) then
430 if isWallAt(X
, Y
) then continue
;
432 VelX
:= vx
+ (Random
-Random
)*3;
433 VelY
:= vy
+ (Random
-Random
)*3;
441 AccelX
:= -Sign(VelX
)*Random
/100;
444 CRnd
:= 20*Random(6);
447 CC
:= CR
+ CRnd
- 50;
448 if CC
< 0 then CC
:= 0;
449 if CC
> 255 then CC
:= 255;
455 CC
:= CG
+ CRnd
- 50;
456 if CC
< 0 then CC
:= 0;
457 if CC
> 255 then CC
:= 255;
463 CC
:= CB
+ CRnd
- 50;
464 if CC
< 0 then CC
:= 0;
465 if CC
> 255 then CC
:= 255;
472 State
:= STATE_NORMAL
;
474 LiveTime
:= 120+Random(40);
475 ParticleType
:= PARTICLE_BLOOD
;
477 {CorrectOffsets(CurrentParticle);}
480 if CurrentParticle
>= MaxParticles
-1 then
483 CurrentParticle
:= CurrentParticle
+1;
488 procedure g_GFX_Spark(fX
, fY
: Integer; Count
: Word; Angle
: SmallInt; DevX
, DevY
: Byte);
494 BaseVelX
, BaseVelY
: Single;
497 l
:= Length(Particles
);
503 Angle
:= 360 - Angle
;
510 b
:= DegToRad(Angle
);
512 BaseVelY
:= 1.6*sin(b
);
513 if Abs(BaseVelX
) < 0.01 then
515 if Abs(BaseVelY
) < 0.01 then
517 for a
:= 1 to Count
do
519 with Particles
[CurrentParticle
] do
521 X
:= fX
-DevX1
+Random(DevX2
);
522 Y
:= fY
-DevY1
+Random(DevY2
);
524 VelX
:= BaseVelX
*Random
;
525 VelY
:= BaseVelY
-Random
;
530 Green
:= 100+Random(155);
534 State
:= STATE_NORMAL
;
536 LiveTime
:= 30+Random(60);
537 ParticleType
:= PARTICLE_SPARK
;
539 {CorrectOffsets(CurrentParticle);}
542 if CurrentParticle
+2 > MaxParticles
then
545 CurrentParticle
:= CurrentParticle
+1;
549 procedure g_GFX_Water(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DevX
, DevY
, Color
: Byte);
556 l
:= Length(Particles
);
562 if Abs(fVelX
) < 3.0 then
563 fVelX
:= 3.0 - 6.0*Random
;
570 for a
:= 1 to Count
do
572 with Particles
[CurrentParticle
] do
574 X
:= fX
-DevX1
+Random(DevX2
);
575 Y
:= fY
-DevY1
+Random(DevY2
);
577 if Abs(fVelX
) < 0.5 then
578 VelX
:= 1.0 - 2.0*Random
580 VelX
:= fVelX
*Random
;
581 if Random(10) < 7 then
583 VelY
:= fVelY
*Random
;
590 Red
:= 155 + Random(9)*10;
591 Green
:= Trunc(150*Random
);
596 Red
:= Trunc(150*Random
);
597 Green
:= 175 + Random(9)*10;
602 Red
:= Trunc(200*Random
);
604 Blue
:= 175 + Random(9)*10;
608 Red
:= 90 + Random(12)*10;
616 State
:= STATE_NORMAL
;
618 LiveTime
:= 60+Random(60);
619 ParticleType
:= PARTICLE_WATER
;
621 {CorrectOffsets(CurrentParticle);}
624 if CurrentParticle
+2 > MaxParticles
then
627 CurrentParticle
:= CurrentParticle
+1;
631 procedure g_GFX_SimpleWater(fX
, fY
: Integer; Count
: Word; fVelX
, fVelY
: Single; DefColor
, CR
, CG
, CB
: Byte);
636 l
:= Length(Particles
);
642 for a
:= 1 to Count
do
644 with Particles
[CurrentParticle
] do
657 Red
:= 155 + Random(9)*10;
658 Green
:= Trunc(150*Random
);
663 Red
:= Trunc(150*Random
);
664 Green
:= 175 + Random(9)*10;
669 Red
:= Trunc(200*Random
);
671 Blue
:= 175 + Random(9)*10;
673 4: // Ñâîé öâåò, ñâåòëåå
675 Red
:= 20 + Random(19)*10;
678 Red
:= Min(Red
+ CR
, 255);
679 Green
:= Min(Green
+ CG
, 255);
680 Blue
:= Min(Blue
+ CB
, 255);
682 5: // Ñâîé öâåò, òåìíåå
684 Red
:= 20 + Random(19)*10;
687 Red
:= Max(CR
- Red
, 0);
688 Green
:= Max(CG
- Green
, 0);
689 Blue
:= Max(CB
- Blue
, 0);
693 Red
:= 90 + Random(12)*10;
701 State
:= STATE_NORMAL
;
703 LiveTime
:= 60+Random(60);
704 ParticleType
:= PARTICLE_WATER
;
706 {CorrectOffsets(CurrentParticle);}
709 if CurrentParticle
+2 > MaxParticles
then
712 CurrentParticle
:= CurrentParticle
+1;
716 procedure g_GFX_Bubbles(fX
, fY
: Integer; Count
: Word; DevX
, DevY
: Byte);
723 l
:= Length(Particles
);
734 for a
:= 1 to Count
do
736 with Particles
[CurrentParticle
] do
738 X
:= fX
-DevX1
+Random(DevX2
);
739 Y
:= fY
-DevY1
+Random(DevY2
);
741 if (X
>= gMapInfo
.Width
) or (X
<= 0) or
742 (Y
>= gMapInfo
.Height
) or (Y
<= 0) then
745 if not isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
758 State
:= STATE_NORMAL
;
761 ParticleType
:= PARTICLE_BUBBLES
;
763 {CorrectOffsets(CurrentParticle);}
766 if CurrentParticle
+2 > MaxParticles
then
769 CurrentParticle
:= CurrentParticle
+1;
773 procedure g_GFX_SetMax(Count
: Integer);
777 if Count
> 50000 then Count
:= 50000;
778 if (Count
< 1) then Count
:= 1;
780 SetLength(Particles
, Count
);
781 for a
:= 0 to High(Particles
) do Particles
[a
].State
:= STATE_FREE
;
782 MaxParticles
:= Count
;
783 //if CurrentParticle >= Count then
784 CurrentParticle
:= 0;
787 function g_GFX_GetMax(): Integer;
789 Result
:= MaxParticles
;
792 function FindOnceAnim
: DWORD
;
796 if OnceAnims
<> nil then
797 for i
:= 0 to High(OnceAnims
) do
798 if OnceAnims
[i
].Animation
= nil then
804 if OnceAnims
= nil then
806 SetLength(OnceAnims
, 16);
811 Result
:= High(OnceAnims
) + 1;
812 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
816 procedure g_GFX_OnceAnim(X
, Y
: Integer; Anim
: TAnimation
; AnimType
: Byte = 0);
823 find_id
:= FindOnceAnim();
825 OnceAnims
[find_id
].AnimType
:= AnimType
;
826 OnceAnims
[find_id
].Animation
:= TAnimation
.Create(Anim
.FramesID
, Anim
.Loop
, Anim
.Speed
);
827 OnceAnims
[find_id
].Animation
.Blending
:= Anim
.Blending
;
828 OnceAnims
[find_id
].Animation
.Alpha
:= Anim
.Alpha
;
829 OnceAnims
[find_id
].X
:= X
;
830 OnceAnims
[find_id
].Y
:= Y
;
833 procedure g_GFX_Update();
842 if not gpart_dbg_enabled
then exit
;
843 if Particles
<> nil then
846 h
:= gMapInfo
.Height
;
848 len
:= High(Particles
);
852 if Particles
[a
].State
<> STATE_FREE
then
856 if Time
= LiveTime
then State
:= STATE_FREE
;
857 if (X
+1 >= w
) or (Y
+1 >= h
) or (X
<= 0) or (Y
<= 0) then State
:= STATE_FREE
;
858 if State
= STATE_FREE
then Continue
;
859 //e_WriteLog(Format('particle #%d: %d', [State, ParticleType]), MSG_NOTIFY);
866 if (State
= STATE_STICK
) then
868 if (not ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)) and
869 (not ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)) and
870 (not ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)) and
871 (not ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED))
874 if (not isBlockedAt(X
, Y
-1)) and
875 (not isBlockedAt(X
, Y
+1)) and
876 (not isBlockedAt(X
-1, Y
)) and
877 (not isBlockedAt(X
+1, Y
))
879 begin // Îòëèïëà - êàïàåò
882 State
:= STATE_NORMAL
;
885 if Random(200) = 100 then
886 begin // Ïðèëåïëåíà - íî âîçìîæíî ñòåêàåò
892 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
894 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
896 if VelY
> -4-Random(3) then
898 if Abs(VelX
) > 0.1 then
899 VelX
:= VelX
- VelX
/10.0;
900 VelX
:= VelX
+ (Random
-Random
)*0.2;
903 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
905 if VelX
> -8-Random(3) then
909 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
910 begin // Ïîòîê âïðàâî
911 if VelX
< 8+Random(3) then
920 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
921 if (State
<> STATE_STICK
) and
922 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
923 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
924 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
925 begin // Âèñèò â âîçäóõå - êàïàåò
928 State
:= STATE_NORMAL
;
942 if (X
+s
>= w
) or (X
+s
<= 0) then
948 //c := gCollideMap[Y, X+s];
950 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
956 State
:= STATE_STICK
;
975 if (Y
+s
>= h
) or (Y
+s
<= 0) then
981 //c := gCollideMap[Y+s, X];
983 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
989 if (s
> 0) and (State
<> STATE_STICK
) then
990 State
:= STATE_NORMAL
992 State
:= STATE_STICK
;
1005 if (X
+dX
>= w
) or (Y
+dY
>= h
) or
1006 (X
+dX
<= 0) or (Y
+dY
<= 0) or
1007 isBlockedAt(X
+dX
, Y
+dY
) {ByteBool(gCollideMap[Y+dY, X+dX] and MARK_BLOCKED)} then
1008 begin // Ñòåíà/äâåðü/ãðàíèöà
1009 State
:= STATE_FREE
;
1020 VelX
:= VelX
+ AccelX
;
1021 VelY
:= VelY
+ AccelY
;
1023 // Êðîâü ðàñòâîðÿåòñÿ â æèäêîñòè:
1024 if isLiquidAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
1028 Alpha
:= 255 - Trunc((255.0 * Time
) / LiveTime
);
1037 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) and
1038 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1039 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1040 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1041 begin // Âèñèò â âîçäóõå
1057 if (X
+s
>= w
) or (X
+s
<= 0) then
1059 State
:= STATE_FREE
;
1063 //c := gCollideMap[Y, X+s];
1065 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1066 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1072 if not isAnythingAt(X
+s
, Y
) {c = MARK_FREE} then
1076 State
:= STATE_FREE
;
1093 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1095 State
:= STATE_FREE
;
1099 //c := gCollideMap[Y+s, X];
1101 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1102 begin // Ñòåíà/äâåðü - ïàäàåò âåðòèêàëüíî
1106 AccelY
:= Abs(AccelY
);
1108 else // Èëè íå ïàäàåò
1119 if not isAnythingAt(X
, Y
+s
) {c = MARK_FREE} then
1123 State
:= STATE_FREE
;
1130 VelX
:= VelX
+ AccelX
;
1134 AccelY
:= AccelY
+ 0.08;
1135 VelY
:= VelY
+ AccelY
;
1143 if (State
= STATE_STICK
) and (Random(30) = 15) then
1144 begin // Ñòåêàåò/îòëèïàåò
1147 if (not isBlockedAt(X
-1, Y
) {ByteBool(gCollideMap[Y, X-1] and MARK_BLOCKED)}) and
1148 (not isBlockedAt(X
+1, Y
) {ByteBool(gCollideMap[Y, X+1] and MARK_BLOCKED)}) then
1149 State
:= STATE_NORMAL
;
1153 if not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)} then
1155 if isLiftUpAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTUP)} then
1157 if VelY
> -4-Random(3) then
1159 if Abs(VelX
) > 0.1 then
1160 VelX
:= VelX
- VelX
/10.0;
1161 VelX
:= VelX
+ (Random
-Random
)*0.2;
1164 if isLiftLeftAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTLEFT)} then
1165 begin // Ïîòîê âëåâî
1166 if VelX
> -8-Random(3) then
1170 if isLiftRightAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_LIFTRIGHT)} then
1171 begin // Ïîòîê âïðàâî
1172 if VelX
< 8+Random(3) then
1181 if (Abs(VelX
) < 0.1) and (Abs(VelY
) < 0.1) then
1182 if (State
<> STATE_STICK
) and
1183 (not isBlockedAt(X
, Y
-1) {ByteBool(gCollideMap[Y-1, X] and MARK_BLOCKED)}) and
1184 (not isBlockedAt(X
, Y
) {ByteBool(gCollideMap[Y, X] and MARK_BLOCKED)}) and
1185 (not isBlockedAt(X
, Y
+1) {ByteBool(gCollideMap[Y+1, X] and MARK_BLOCKED)}) then
1186 begin // Âèñèò â âîçäóõå - êàïàåò
1189 State
:= STATE_NORMAL
;
1199 for b
:= 1 to Abs(dX
) do
1201 if (X
+s
>= w
) or (X
+s
<= 0) then
1202 begin // Ñáîêó ãðàíèöà
1203 State
:= STATE_FREE
;
1207 //c := gCollideMap[Y, X+s];
1209 if isLiquidAt(X
+s
, Y
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1210 begin // Ñáîêó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1211 State
:= STATE_FREE
;
1215 if isBlockedAt(X
+s
, Y
) {ByteBool(c and MARK_BLOCKED)} then
1216 begin // Ñòåíà/äâåðü
1221 State
:= STATE_STICK
;
1236 for b
:= 1 to Abs(dY
) do
1238 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1239 begin // Ñíèçó/ñâåðõó ãðàíèöà
1240 State
:= STATE_FREE
;
1244 //c := gCollideMap[Y+s, X];
1246 if isLiquidAt(X
, Y
+s
) {ByteBool(c and MARK_LIQUID)} and (dY
> 0) then
1247 begin // Ñíèçó æèäêîñòü, à ÷àñòèöà óæå ïàäàåò
1248 State
:= STATE_FREE
;
1252 if isBlockedAt(X
, Y
+s
) {ByteBool(c and MARK_BLOCKED)} then
1253 begin // Ñòåíà/äâåðü
1258 if (s
> 0) and (State
<> STATE_STICK
) then
1259 State
:= STATE_NORMAL
1261 State
:= STATE_STICK
;
1269 VelX
:= VelX
+ AccelX
;
1270 VelY
:= VelY
+ AccelY
;
1286 for b
:= 1 to Abs(dY
) do
1288 if (Y
+s
>= h
) or (Y
+s
<= 0) then
1290 State
:= STATE_FREE
;
1294 if not isLiquidAt(X
, Y
+s
) {ByteBool(gCollideMap[Y+s, X] and MARK_LIQUID)} then
1295 begin // Óæå íå æèäêîñòü
1296 State
:= STATE_FREE
;
1305 VelY
:= VelY
+ AccelY
;
1311 {CorrectOffsets(a);}
1315 end; // Particles <> nil
1317 if OnceAnims
<> nil then
1319 for a
:= 0 to High(OnceAnims
) do
1320 if OnceAnims
[a
].Animation
<> nil then
1322 case OnceAnims
[a
].AnimType
of
1325 if Random(3) = 0 then
1326 OnceAnims
[a
].X
:= OnceAnims
[a
].X
-1+Random(3);
1327 if Random(2) = 0 then
1328 OnceAnims
[a
].Y
:= OnceAnims
[a
].Y
-Random(2);
1332 if OnceAnims
[a
].Animation
.Played
then
1334 OnceAnims
[a
].Animation
.Free();
1335 OnceAnims
[a
].Animation
:= nil;
1338 OnceAnims
[a
].Animation
.Update();
1343 procedure g_GFX_Draw();
1347 if Particles
<> nil then
1349 glDisable(GL_TEXTURE_2D
);
1353 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1357 len
:= High(Particles
);
1359 for a
:= 0 to len
do
1360 with Particles
[a
] do
1361 if (State
<> STATE_FREE
) and (X
>= sX
) and (Y
>= sY
) and
1362 (X
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
1364 glColor4ub(Red
, Green
, Blue
, Alpha
);
1365 glVertex2i(X
+ offsetX
, Y
+ offsetY
);
1370 glDisable(GL_BLEND
);
1373 if OnceAnims
<> nil then
1374 for a
:= 0 to High(OnceAnims
) do
1375 if OnceAnims
[a
].Animation
<> nil then
1376 with OnceAnims
[a
] do
1377 Animation
.Draw(X
, Y
, M_NONE
);