hedgewars/uCollisions.pas
author nemo
Tue, 19 Nov 2013 22:15:40 -0500
changeset 9706 5178d2263521
parent 9305 8e5140875ab5
child 9708 7d146637cb81
permissions -rw-r--r--
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 967
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9080
9b42757d7e71 bump copyright year for Andrey entries
unc0rr
parents: 9041
diff changeset
     3
 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    19
{$INCLUDE "options.inc"}
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    20
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
unit uCollisions;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
interface
4357
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 3697
diff changeset
    23
uses uFloat, uTypes;
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    24
5290
eea7570d345f This can afford to be a bit larger. Does not impact performance.
nemo
parents: 4976
diff changeset
    25
const cMaxGearArrayInd = 1023;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
    27
type PGearArray = ^TGearArray;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    28
    TGearArray = record
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    29
        ar: array[0..cMaxGearArrayInd] of PGear;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    30
        Count: Longword
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    31
        end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
    33
procedure initModule;
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
    34
procedure freeModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    35
9291
15f7bb217b66 Make add/delete consistent (this has bugged me for so long)
nemo
parents: 9247
diff changeset
    36
procedure AddCI(Gear: PGear);
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    37
procedure DeleteCI(Gear: PGear);
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
    38
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    39
function  CheckGearsCollision(Gear: PGear): PGearArray;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
    40
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    41
function  TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word;
6081
537bbd5c1a62 Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents: 5919
diff changeset
    42
function  TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
    43
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    44
function  TestCollisionXKick(Gear: PGear; Dir: LongInt): Word;
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    45
function  TestCollisionYKick(Gear: PGear; Dir: LongInt): Word;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
    46
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    47
function  TestCollisionX(Gear: PGear; Dir: LongInt): Word;
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    48
function  TestCollisionY(Gear: PGear; Dir: LongInt): Word;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
    49
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    50
function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    51
function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    52
function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    53
function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
    55
function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
    56
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
    57
// returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5)
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
    58
function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
    59
function  CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
    60
function  CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
    61
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    62
implementation
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6990
diff changeset
    63
uses uConsts, uLandGraphics, uVariables, uDebug, uGearsList;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    65
type TCollisionEntry = record
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    66
    X, Y, Radius: LongInt;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    67
    cGear: PGear;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    68
    end;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
    69
5568
badaac85f9d4 bump up max collision to 1024 entries
nemo
parents: 5290
diff changeset
    70
const MAXRECTSINDEX = 1023;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    71
var Count: Longword;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    72
    cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    73
    ga: TGearArray;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    74
9291
15f7bb217b66 Make add/delete consistent (this has bugged me for so long)
nemo
parents: 9247
diff changeset
    75
procedure AddCI(Gear: PGear);
5569
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    76
var t: PGear;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    77
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    78
if Gear^.CollisionIndex >= 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    79
    exit;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    81
with cinfos[Count] do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    82
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    83
    X:= hwRound(Gear^.X);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    84
    Y:= hwRound(Gear^.Y);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    85
    Radius:= Gear^.Radius;
9247
68bbe56badcc poor AI thought he should avoid stepping on frozen crates, and jump for non-frozen ones
nemo
parents: 9080
diff changeset
    86
    ChangeRoundInLand(X, Y, Radius - 1, true, (Gear = CurrentHedgehog^.Gear) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0)));
3608
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
    87
    cGear:= Gear
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    88
    end;
511
2b5b9e00419d - Further work on new collisions implementation
unc0rr
parents: 505
diff changeset
    89
Gear^.CollisionIndex:= Count;
5569
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    90
inc(Count);
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    91
// mines are the easiest way to overflow collision
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    92
if (Count > (MAXRECTSINDEX-20)) then
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    93
    begin
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    94
    t:= GearsList;
5572
47cc28299baa Why so suspicious?
unc0rr
parents: 5569
diff changeset
    95
    while (t <> nil) and (t^.Kind <> gtMine) do 
47cc28299baa Why so suspicious?
unc0rr
parents: 5569
diff changeset
    96
        t:= t^.NextGear;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    97
    if (t <> nil) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
    98
        DeleteGear(t)
5569
8313952b2811 suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents: 5568
diff changeset
    99
    end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   102
procedure DeleteCI(Gear: PGear);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
begin
511
2b5b9e00419d - Further work on new collisions implementation
unc0rr
parents: 505
diff changeset
   104
if Gear^.CollisionIndex >= 0 then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   105
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   106
    with cinfos[Gear^.CollisionIndex] do
9247
68bbe56badcc poor AI thought he should avoid stepping on frozen crates, and jump for non-frozen ones
nemo
parents: 9080
diff changeset
   107
        ChangeRoundInLand(X, Y, Radius - 1, false, (Gear = CurrentHedgehog^.Gear) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0)));
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   108
    cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   109
    cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   110
    Gear^.CollisionIndex:= -1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   111
    dec(Count)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   112
    end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   113
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   114
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   115
function CheckGearsCollision(Gear: PGear): PGearArray;
3609
bc63ed514b70 Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents: 3608
diff changeset
   116
var mx, my, tr: LongInt;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   117
    i: Longword;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
begin
1506
a4ab75470ce1 - Some reformatting
unc0rr
parents: 1066
diff changeset
   119
CheckGearsCollision:= @ga;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   120
ga.Count:= 0;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   121
if Count = 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   122
    exit;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   123
mx:= hwRound(Gear^.X);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   124
my:= hwRound(Gear^.Y);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
4705
593ef1ad3cd3 ok. restore old [r + 1 + r] for gear width for a moment, and reset snowballs.
nemo
parents: 4684
diff changeset
   126
tr:= Gear^.Radius + 2;
3609
bc63ed514b70 Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents: 3608
diff changeset
   127
3608
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   128
for i:= 0 to Pred(Count) do
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   129
    with cinfos[i] do
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   130
        if (Gear <> cGear) and
3609
bc63ed514b70 Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents: 3608
diff changeset
   131
            (sqr(mx - x) + sqr(my - y) <= sqr(Radius + tr)) then
3608
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   132
                begin
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   133
                ga.ar[ga.Count]:= cinfos[i].cGear;
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   134
                inc(ga.Count)
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   135
                end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   136
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   137
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   138
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   139
var x, y, i: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   140
begin
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   141
// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
8751
4609823efc94 More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents: 8744
diff changeset
   142
if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   143
    ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.X) - Gear^.Radius) or
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   144
     (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.X) + Gear^.Radius)) then
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   145
    Gear^.CollisionMask:= $FFFF;
838
1faae19f2116 Remove tailing spaces in some places
unc0rr
parents: 542
diff changeset
   146
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   147
x:= hwRound(Gear^.X);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   148
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   149
    x:= x - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   150
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   151
    x:= x + Gear^.Radius;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   152
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   153
if (x and LAND_WIDTH_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   154
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   155
    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   156
    i:= y + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   157
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   158
        if (y and LAND_HEIGHT_MASK) = 0 then
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   159
            if Land[y, x] and Gear^.CollisionMask <> 0 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   160
                exit(Land[y, x]);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   161
        inc(y)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   162
    until (y > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   163
    end;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   164
TestCollisionXwithGear:= 0
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   165
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   166
6081
537bbd5c1a62 Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents: 5919
diff changeset
   167
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   168
var x, y, i: LongInt;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   169
begin
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   170
// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
8751
4609823efc94 More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents: 8744
diff changeset
   171
if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   172
    ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.Y) - Gear^.Radius) or
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   173
     (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.Y) + Gear^.Radius)) then
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   174
    Gear^.CollisionMask:= $FFFF;
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   175
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   176
y:= hwRound(Gear^.Y);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   177
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   178
    y:= y - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   179
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   180
    y:= y + Gear^.Radius;
7268
3a61c53346a8 - Fix cake bug introduced in r2ccfc93c6b5e
unc0rr
parents: 6992
diff changeset
   181
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   182
if (y and LAND_HEIGHT_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   183
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   184
    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   185
    i:= x + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   186
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   187
        if (x and LAND_WIDTH_MASK) = 0 then
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   188
            if Land[y, x] and Gear^.CollisionMask <> 0 then
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   189
                begin
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   190
                TestCollisionYwithGear:= Land[y, x];
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   191
                exit(Land[y, x]);
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   192
                end;
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7270
diff changeset
   193
        inc(x)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   194
    until (x > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   195
    end;
6081
537bbd5c1a62 Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents: 5919
diff changeset
   196
TestCollisionYwithGear:= 0
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   197
end;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   198
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   199
function TestCollisionXKick(Gear: PGear; Dir: LongInt): Word;
3608
c509bbc779e7 Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents: 3603
diff changeset
   200
var x, y, mx, my, i: LongInt;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   201
    pixel: Word;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   202
begin
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   203
pixel:= 0;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   204
x:= hwRound(Gear^.X);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   205
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   206
    x:= x - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   207
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   208
    x:= x + Gear^.Radius;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   209
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   210
if (x and LAND_WIDTH_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   211
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   212
    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   213
    i:= y + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   214
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   215
        if (y and LAND_HEIGHT_MASK) = 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   216
            if Land[y, x] > 255 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   217
                exit(Land[y, x])
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   218
            else if Land[y, x] <> 0 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   219
                pixel:= Land[y, x];
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   220
    inc(y)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   221
    until (y > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   222
    end;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   223
TestCollisionXKick:= pixel;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   224
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   225
if pixel <> 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   226
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   227
    if hwAbs(Gear^.dX) < cHHKick then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   228
        exit;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   229
    if (Gear^.State and gstHHJumping <> 0)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   230
    and (hwAbs(Gear^.dX) < _0_4) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   231
        exit;
967
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   232
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   233
    mx:= hwRound(Gear^.X);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   234
    my:= hwRound(Gear^.Y);
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   235
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   236
    for i:= 0 to Pred(Count) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   237
        with cinfos[i] do
9305
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   238
            if  (Gear <> cGear) and 
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   239
                ((mx > x) xor (Dir > 0)) and
7756
b89bd0ffb8aa Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents: 7754
diff changeset
   240
                (
b89bd0ffb8aa Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents: 7754
diff changeset
   241
                  ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   242
                // only apply X kick if the barrel is knocked over
9305
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   243
                  ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   244
                ) and
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   245
                (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   246
                    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   247
                    with cGear^ do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   248
                        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   249
                        dX:= Gear^.dX;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   250
                        dY:= Gear^.dY * _0_5;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   251
                        State:= State or gstMoving;
7767
d1ea9b3f543e damn nots
nemo
parents: 7756
diff changeset
   252
                        if Kind = gtKnife then State:= State and (not gstCollision);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   253
                        Active:= true
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   254
                        end;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   255
                    DeleteCI(cGear);
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   256
                    exit(0);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   257
                    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   258
    end
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   259
end;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   260
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   261
function TestCollisionYKick(Gear: PGear; Dir: LongInt): Word;
7756
b89bd0ffb8aa Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents: 7754
diff changeset
   262
var x, y, mx, my,  myr, i: LongInt;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   263
    pixel: Word;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   264
begin
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   265
pixel:= 0;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   266
y:= hwRound(Gear^.Y);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   267
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   268
    y:= y - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   269
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   270
    y:= y + Gear^.Radius;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   271
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   272
if (y and LAND_HEIGHT_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   273
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   274
    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   275
    i:= x + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   276
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   277
    if (x and LAND_WIDTH_MASK) = 0 then
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   278
        if Land[y, x] > 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   279
            if Land[y, x] > 255 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   280
                exit(Land[y, x])
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   281
            else if Land[y, x] <> 0 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   282
                pixel:= Land[y, x];
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   283
    inc(x)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   284
    until (x > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   285
    end;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   286
TestCollisionYKick:= pixel;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   287
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   288
if pixel <> 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   289
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   290
    if hwAbs(Gear^.dY) < cHHKick then
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   291
        exit;
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   292
    if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   293
        exit;
967
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   294
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   295
    mx:= hwRound(Gear^.X);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   296
    my:= hwRound(Gear^.Y);
7756
b89bd0ffb8aa Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents: 7754
diff changeset
   297
    myr:= my+Gear^.Radius;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   298
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   299
    for i:= 0 to Pred(Count) do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   300
        with cinfos[i] do
9305
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   301
            if (Gear <> cGear) and
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   302
               ((myr > y) xor (Dir > 0)) and
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   303
               (Gear^.State and gstNotKickable = 0) and
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   304
               (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
8e5140875ab5 bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents: 9291
diff changeset
   305
               (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   306
                    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   307
                    with cGear^ do
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   308
                        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   309
                        if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   310
                            dX:= Gear^.dX * _0_5;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   311
                        dY:= Gear^.dY;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   312
                        State:= State or gstMoving;
7767
d1ea9b3f543e damn nots
nemo
parents: 7756
diff changeset
   313
                        if Kind = gtKnife then State:= State and (not gstCollision);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   314
                        Active:= true
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   315
                        end;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   316
                    DeleteCI(cGear);
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   317
                    exit(0)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   318
                    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   319
    end
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   320
end;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   321
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   322
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   323
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   324
    TestCollisionXwithXYShift:= TestCollisionXwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   325
end;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   326
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   327
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   328
begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   329
Gear^.X:= Gear^.X + ShiftX;
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   330
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
5750
6bbf7aee2cdf Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
nemo
parents: 5572
diff changeset
   331
if withGear then 
6bbf7aee2cdf Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
nemo
parents: 5572
diff changeset
   332
    TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir)
6bbf7aee2cdf Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
nemo
parents: 5572
diff changeset
   333
else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   334
Gear^.X:= Gear^.X - ShiftX;
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   335
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   336
end;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   337
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   338
function TestCollisionX(Gear: PGear; Dir: LongInt): Word;
4798
84fb1ff0a1c0 fix sticky rope issue
sheepluva
parents: 4705
diff changeset
   339
var x, y, i: LongInt;
84fb1ff0a1c0 fix sticky rope issue
sheepluva
parents: 4705
diff changeset
   340
begin
84fb1ff0a1c0 fix sticky rope issue
sheepluva
parents: 4705
diff changeset
   341
x:= hwRound(Gear^.X);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   342
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   343
    x:= x - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   344
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   345
    x:= x + Gear^.Radius;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   346
4798
84fb1ff0a1c0 fix sticky rope issue
sheepluva
parents: 4705
diff changeset
   347
if (x and LAND_WIDTH_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   348
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   349
    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   350
    i:= y + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   351
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   352
        if (y and LAND_HEIGHT_MASK) = 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   353
            if Land[y, x] > 255 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   354
                exit(Land[y, x]);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   355
    inc(y)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   356
    until (y > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   357
    end;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   358
TestCollisionX:= 0
4798
84fb1ff0a1c0 fix sticky rope issue
sheepluva
parents: 4705
diff changeset
   359
end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   360
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   361
function TestCollisionY(Gear: PGear; Dir: LongInt): Word;
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   362
var x, y, i: LongInt;
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   363
begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   364
y:= hwRound(Gear^.Y);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   365
if Dir < 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   366
    y:= y - Gear^.Radius
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   367
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   368
    y:= y + Gear^.Radius;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   369
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   370
if (y and LAND_HEIGHT_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   371
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   372
    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   373
    i:= x + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   374
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   375
        if (x and LAND_WIDTH_MASK) = 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   376
            if Land[y, x] > 255 then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   377
                exit(Land[y, x]);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   378
    inc(x)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   379
    until (x > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   380
    end;
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   381
TestCollisionY:= 0
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   382
end;
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   383
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   384
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   385
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   386
    TestCollisionYwithXYShift:= TestCollisionYwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   387
end;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6700
diff changeset
   388
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   389
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
begin
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   391
Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   392
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   393
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   394
if withGear then
9706
5178d2263521 return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents: 9305
diff changeset
   395
  TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   396
else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   397
  TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   398
  
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   399
Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   400
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   403
function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   404
var x, y: LongInt;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   405
    TestWord: LongWord;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   406
begin
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   407
TestRectancleForObstacle:= true;
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   408
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   409
if landOnly then
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   410
    TestWord:= 255
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   411
else
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   412
    TestWord:= 0;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   413
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   414
if x1 > x2 then
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   415
begin
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   416
    x  := x1;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   417
    x1 := x2;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   418
    x2 := x;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   419
end;
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   420
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   421
if y1 > y2 then
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   422
begin
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   423
    y  := y1;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   424
    y1 := y2;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   425
    y2 := y;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   426
end;
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   427
5919
f737843dd331 TestRectForObstacle: areas outside map borders are not passable
sheepluva
parents: 5896
diff changeset
   428
if (hasBorder and ((y1 < 0) or (x1 < 0) or (x2 > LAND_WIDTH))) then
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   429
    exit;
5919
f737843dd331 TestRectForObstacle: areas outside map borders are not passable
sheepluva
parents: 5896
diff changeset
   430
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   431
for y := y1 to y2 do
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   432
    for x := x1 to x2 do
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   433
        if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   434
            exit;
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   435
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   436
TestRectancleForObstacle:= false
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   437
end;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   438
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5834
diff changeset
   439
function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   440
var ldx, ldy, rdx, rdy: LongInt;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   441
    i, j, k, mx, my, li, ri, jfr, jto, tmpo : ShortInt;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   442
    tmpx, tmpy: LongWord;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   443
    dx, dy, s: hwFloat;
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6279
diff changeset
   444
    offset: array[0..7,0..1] of ShortInt;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   445
    isColl: Boolean;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   446
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   447
begin
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   448
    CalcSlopeTangent:= false;
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   449
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   450
    dx:= Gear^.dX;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   451
    dy:= Gear^.dY;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   452
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   453
    // we start searching from the direction the gear came from
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   454
    if (dx.QWordValue > _0_995.QWordValue )
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   455
    or (dy.QWordValue > _0_995.QWordValue ) then
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   456
        begin // scale
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   457
        s := _0_995 / Distance(dx,dy);
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   458
        dx := s * dx;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   459
        dy := s * dy;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   460
        end;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   461
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   462
    mx:= hwRound(Gear^.X-dx) - hwRound(Gear^.X);
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   463
    my:= hwRound(Gear^.Y-dy) - hwRound(Gear^.Y);
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   464
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   465
    li:= -1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   466
    ri:= -1;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   467
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   468
    // go around collision pixel, checking for first/last collisions
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   469
    // this will determinate what angles will be tried to crawl along
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   470
    for i:= 0 to 7 do
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   471
        begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   472
        offset[i,0]:= mx;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   473
        offset[i,1]:= my;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   474
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   475
        // multiplicator k tries to skip small pixels/gaps when possible
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   476
        for k:= 4 downto 1 do
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   477
            begin
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   478
            tmpx:= collisionX + k * mx;
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   479
            tmpy:= collisionY + k * my;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   480
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   481
            if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) then
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   482
                if (Land[tmpy,tmpx] > TestWord) then
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   483
                    begin
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   484
                    // remember the index belonging to the first and last collision (if in 1st half)
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   485
                    if (i <> 0) then
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   486
                        begin
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   487
                        if (ri = -1) then
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   488
                            ri:= i
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   489
                        else
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   490
                            li:= i;
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   491
                        end;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   492
                    end;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   493
            end;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   494
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   495
        if i = 7 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   496
            break;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   497
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   498
        // prepare offset for next check (clockwise)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   499
        if (mx = -1) and (my <> -1) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   500
            my:= my - 1
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   501
        else if (my = -1) and (mx <> 1) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   502
            mx:= mx + 1
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   503
        else if (mx = 1) and (my <> 1) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   504
            my:= my + 1
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   505
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   506
            mx:= mx - 1;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   507
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   508
        end;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   509
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   510
    ldx:= collisionX;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   511
    ldy:= collisionY;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   512
    rdx:= collisionX;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   513
    rdy:= collisionY;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   514
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   515
    // edge-crawl
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   516
    for i:= 0 to 8 do
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   517
        begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   518
        // using mx,my as temporary value buffer here
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3609
diff changeset
   519
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   520
        jfr:= 8+li+1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   521
        jto:= 8+li-1;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   522
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   523
        isColl:= false;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   524
        for j:= jfr downto jto do
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   525
            begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   526
            tmpo:= j mod 8;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   527
            // multiplicator k tries to skip small pixels/gaps when possible
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   528
            for k:= 3 downto 1 do
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   529
                begin
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   530
                tmpx:= ldx + k * offset[tmpo,0];
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   531
                tmpy:= ldy + k * offset[tmpo,1];
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   532
                if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK)  = 0)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   533
                and (Land[tmpy,tmpx] > TestWord) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   534
                    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   535
                    ldx:= tmpx;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   536
                    ldy:= tmpy;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   537
                    isColl:= true;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   538
                    break;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   539
                    end;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   540
                end;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   541
            if isColl then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   542
                break;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   543
            end;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   544
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   545
        jfr:= 8+ri-1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   546
        jto:= 8+ri+1;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   547
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   548
        isColl:= false;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   549
        for j:= jfr to jto do
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   550
            begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   551
            tmpo:= j mod 8;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   552
            for k:= 3 downto 1 do
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   553
                begin
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   554
                tmpx:= rdx + k * offset[tmpo,0];
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   555
                tmpy:= rdy + k * offset[tmpo,1];
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   556
                if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK)  = 0)
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   557
                and (Land[tmpy,tmpx] > TestWord) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   558
                    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   559
                    rdx:= tmpx;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   560
                    rdy:= tmpy;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   561
                    isColl:= true;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   562
                    break;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   563
                    end;
6123
0cb751caf0ac make slope calcs skip small gaps
sheepluva
parents: 6081
diff changeset
   564
                end;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   565
            if isColl then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   566
                break;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   567
            end;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   568
        end;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   569
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   570
    ldx:= rdx - ldx;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   571
    ldy:= rdy - ldy;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   572
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   573
    if ((ldx = 0) and (ldy = 0)) then
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   574
        exit;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   575
3414
b2f3bb44777e some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents: 3411
diff changeset
   576
outDeltaX:= ldx;
b2f3bb44777e some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents: 3411
diff changeset
   577
outDeltaY:= ldy;
6990
40e5af28d026 change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents: 6986
diff changeset
   578
CalcSlopeTangent:= true;
3401
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   579
end;
d5d31d16eccc add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents: 3236
diff changeset
   580
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   581
function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   582
var dx, dy: hwFloat;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   583
    collX, collY, i, y, x, gx, gy, sdx, sdy: LongInt;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   584
    isColl, bSucc: Boolean;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   585
begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   586
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   587
if dirY <> 0 then 
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   588
    begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   589
    y:= hwRound(Gear^.Y) + Gear^.Radius * dirY;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   590
    gx:= hwRound(Gear^.X);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   591
    collX := gx;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   592
    isColl:= false;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   593
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   594
    if (y and LAND_HEIGHT_MASK) = 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   595
        begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   596
        x:= hwRound(Gear^.X) - Gear^.Radius + 1;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   597
        i:= x + Gear^.Radius * 2 - 2;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   598
        repeat
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   599
        if (x and LAND_WIDTH_MASK) = 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   600
            if Land[y, x] <> 0 then
7767
d1ea9b3f543e damn nots
nemo
parents: 7756
diff changeset
   601
                if (not isColl) or (abs(x-gx) < abs(collX-gx)) then
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   602
                    begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   603
                    isColl:= true;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   604
                    collX := x;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   605
                    end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   606
        inc(x)
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   607
        until (x > i);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   608
        end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   609
    end
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   610
else
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   611
    begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   612
    x:= hwRound(Gear^.X) + Gear^.Radius * dirX;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   613
    gy:= hwRound(Gear^.Y);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   614
    collY := gy;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   615
    isColl:= false;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   616
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   617
    if (x and LAND_WIDTH_MASK) = 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   618
        begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   619
        y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   620
        i:= y + Gear^.Radius * 2 - 2;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   621
        repeat
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   622
        if (y and LAND_HEIGHT_MASK) = 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   623
            if Land[y, x] <> 0 then
7767
d1ea9b3f543e damn nots
nemo
parents: 7756
diff changeset
   624
                if (not isColl) or (abs(y-gy) < abs(collY-gy)) then
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   625
                    begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   626
                    isColl:= true;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   627
                    collY := y;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   628
                    end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   629
        inc(y)
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   630
        until (y > i);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   631
        end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   632
    end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   633
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   634
if isColl then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   635
    begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   636
    // save original dx/dy
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   637
    dx := Gear^.dX;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   638
    dy := Gear^.dY;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   639
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   640
    if dirY <> 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   641
        begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   642
        Gear^.dX.QWordValue:= 0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   643
        Gear^.dX.isNegative:= (collX >= gx);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   644
        Gear^.dY:= _1*dirY
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   645
        end
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   646
    else
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   647
        begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   648
        Gear^.dY.QWordValue:= 0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   649
        Gear^.dY.isNegative:= (collY >= gy);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   650
        Gear^.dX:= _1*dirX
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   651
        end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   652
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   653
    sdx:= 0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   654
    sdy:= 0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   655
    if dirY <> 0 then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   656
         bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 0)
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   657
    else bSucc := CalcSlopeTangent(Gear, x, collY, sdx, sdy, 0);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   658
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   659
    // restore original dx/dy
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   660
    Gear^.dX := dx;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   661
    Gear^.dY := dy;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   662
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   663
    if bSucc and ((sdx <> 0) or (sdy <> 0)) then
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   664
        begin
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   665
        dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy));
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   666
        dx.isNegative := (sdx * sdy) < 0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   667
        exit (dx);
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   668
        end
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   669
    end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   670
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   671
CalcSlopeNearGear := _0;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   672
end;
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7489
diff changeset
   673
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   674
function CalcSlopeBelowGear(Gear: PGear): hwFloat;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   675
var dx, dy: hwFloat;
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   676
    collX, i, y, x, gx, sdx, sdy: LongInt;
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6279
diff changeset
   677
    isColl, bSucc: Boolean;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   678
begin
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   679
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   680
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   681
y:= hwRound(Gear^.Y) + Gear^.Radius;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   682
gx:= hwRound(Gear^.X);
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   683
collX := gx;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   684
isColl:= false;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   685
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   686
if (y and LAND_HEIGHT_MASK) = 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   687
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   688
    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   689
    i:= x + Gear^.Radius * 2 - 2;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   690
    repeat
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   691
    if (x and LAND_WIDTH_MASK) = 0 then
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   692
        if Land[y, x] > 255 then
7767
d1ea9b3f543e damn nots
nemo
parents: 7756
diff changeset
   693
            if (not isColl) or (abs(x-gx) < abs(collX-gx)) then
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   694
                begin
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   695
                isColl:= true;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   696
                collX := x;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   697
                end;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   698
    inc(x)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   699
    until (x > i);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6543
diff changeset
   700
    end;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   701
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   702
if isColl then
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   703
    begin
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   704
    // save original dx/dy
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   705
    dx := Gear^.dX;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   706
    dy := Gear^.dY;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   707
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   708
    Gear^.dX.QWordValue:= 0;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   709
    Gear^.dX.isNegative:= (collX >= gx);
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   710
    Gear^.dY:= _1;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   711
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   712
    sdx:= 0;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   713
    sdy:= 0;
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6279
diff changeset
   714
    bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 255);
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   715
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   716
    // restore original dx/dy
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   717
    Gear^.dX := dx;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   718
    Gear^.dY := dy;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   719
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6279
diff changeset
   720
    if bSucc and (sdx <> 0) and (sdy <> 0) then
6279
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   721
    begin
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   722
        dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy));
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   723
        dx.isNegative := (sdx * sdy) < 0;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   724
        exit (dx);
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   725
    end;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   726
    end;
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   727
7f724835ea57 I hope this helps...
sheepluva
parents: 6124
diff changeset
   728
CalcSlopeBelowGear := _0;
6124
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   729
end;
bee90df26109 something for nemo to play around with
sheepluva
parents: 6123
diff changeset
   730
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
   731
procedure initModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   732
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   733
    Count:= 0;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   734
end;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   735
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
   736
procedure freeModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   737
begin
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   738
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   739
end;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   740
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   741
end.