equal
deleted
inserted
replaced
42 end; |
42 end; |
43 |
43 |
44 procedure AddGearCR(Gear: PGear); |
44 procedure AddGearCR(Gear: PGear); |
45 procedure UpdateCR(NewX, NewY: integer; Index: Longword); |
45 procedure UpdateCR(NewX, NewY: integer; Index: Longword); |
46 procedure DeleteCR(Gear: PGear); |
46 procedure DeleteCR(Gear: PGear); |
47 function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): boolean; |
47 function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): PGear; |
48 function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
48 function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
49 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
49 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
50 function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
50 function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
51 function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
51 function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
52 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
52 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
92 end; |
92 end; |
93 Gear.CollIndex:= High(Longword); |
93 Gear.CollIndex:= High(Longword); |
94 dec(Count) |
94 dec(Count) |
95 end; |
95 end; |
96 |
96 |
97 function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): boolean; |
97 function CheckGearsCollision(Gear: PGear; Dir: integer; forX: boolean): PGear; |
98 var x1, x2, y1, y2: integer; |
98 var x1, x2, y1, y2: integer; |
99 i: Longword; |
99 i: Longword; |
100 begin |
100 begin |
101 Result:= false; |
101 Result:= nil; |
102 if Count = 0 then exit; |
102 if Count = 0 then exit; |
103 x1:= round(Gear.X); |
103 x1:= round(Gear.X); |
104 y1:= round(Gear.Y); |
104 y1:= round(Gear.Y); |
105 |
105 |
106 if forX then |
106 if forX then |
123 and (x1 <= X + HWidth) |
123 and (x1 <= X + HWidth) |
124 and (x2 >= X - HWidth) |
124 and (x2 >= X - HWidth) |
125 and (y1 <= Y + HHeight) |
125 and (y1 <= Y + HHeight) |
126 and (y2 >= Y - HHeight) then |
126 and (y2 >= Y - HHeight) then |
127 begin |
127 begin |
128 Result:= true; |
128 Result:= crects[i].cGear; |
129 exit |
129 exit |
130 end; |
130 end; |
131 end; |
131 end; |
132 |
132 |
133 function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
133 function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean; |
157 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
157 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
158 inc(x) |
158 inc(x) |
159 until (x > i) or Result; |
159 until (x > i) or Result; |
160 if Result then exit; |
160 if Result then exit; |
161 |
161 |
162 Result:= CheckGearsCollision(Gear, Dir, false) |
162 Result:= CheckGearsCollision(Gear, Dir, false) <> nil |
163 end |
163 end |
164 end; |
164 end; |
165 |
165 |
166 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
166 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
167 var x, y, i: integer; |
167 var x, y, i: integer; |
177 repeat |
177 repeat |
178 if (y and $FFFFFC00) = 0 then Result:= Land[y, x]<>0; |
178 if (y and $FFFFFC00) = 0 then Result:= Land[y, x]<>0; |
179 inc(y) |
179 inc(y) |
180 until (y > i) or Result; |
180 until (y > i) or Result; |
181 if Result then exit; |
181 if Result then exit; |
182 Result:= CheckGearsCollision(Gear, Dir, true) |
182 Result:= CheckGearsCollision(Gear, Dir, true) <> nil |
183 end |
183 end |
184 end; |
184 end; |
185 |
185 |
186 function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
186 function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean; |
187 begin |
187 begin |
206 repeat |
206 repeat |
207 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
207 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
208 inc(x) |
208 inc(x) |
209 until (x > i) or Result; |
209 until (x > i) or Result; |
210 if Result then exit; |
210 if Result then exit; |
211 Result:= CheckGearsCollision(Gear, Dir, false); |
211 Result:= CheckGearsCollision(Gear, Dir, false) <> nil; |
212 end |
212 end |
213 end; |
213 end; |
214 |
214 |
215 function TestCollisionY(Gear: PGear; Dir: integer): boolean; |
215 function TestCollisionY(Gear: PGear; Dir: integer): boolean; |
216 var x, y, i: integer; |
216 var x, y, i: integer; |