equal
deleted
inserted
replaced
1 (* |
1 (* |
2 * Hedgewars, a worms-like game |
2 * Hedgewars, a worms-like game |
3 * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * Distributed under the terms of the BSD-modified licence: |
5 * Distributed under the terms of the BSD-modified licence: |
6 * |
6 * |
7 * Permission is hereby granted, free of charge, to any person obtaining a copy |
7 * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 * of this software and associated documentation files (the "Software"), to deal |
8 * of this software and associated documentation files (the "Software"), to deal |
149 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
149 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean; |
150 var x, y, i: integer; |
150 var x, y, i: integer; |
151 begin |
151 begin |
152 Result:= false; |
152 Result:= false; |
153 x:= round(Gear.X); |
153 x:= round(Gear.X); |
154 if Dir < 0 then x:= x - Gear.Radius |
154 if Dir < 0 then x:= x - Gear.Radius - 1 |
155 else x:= x + Gear.Radius; |
155 else x:= x + Gear.Radius + 1; |
156 if (x and $FFFFF800) = 0 then |
156 if (x and $FFFFF800) = 0 then |
157 begin |
157 begin |
158 y:= round(Gear.Y) - Gear.Radius + 1; {*} |
158 y:= round(Gear.Y) - Gear.Radius + 1; |
159 i:= y + Gear.Radius * 2 - 2; {*} |
159 i:= y + Gear.Radius * 2 - 2; |
160 repeat |
160 repeat |
161 if (y and $FFFFFC00) = 0 then Result:= Land[y, x]<>0; |
161 if (y and $FFFFFC00) = 0 then Result:= Land[y, x]<>0; |
162 inc(y) |
162 inc(y) |
163 until (y > i) or Result; |
163 until (y > i) or Result; |
164 end |
164 end |
180 y:= round(Gear.Y); |
180 y:= round(Gear.Y); |
181 if Dir < 0 then y:= y - Gear.Radius |
181 if Dir < 0 then y:= y - Gear.Radius |
182 else y:= y + Gear.Radius; |
182 else y:= y + Gear.Radius; |
183 if (y and $FFFFFC00) = 0 then |
183 if (y and $FFFFFC00) = 0 then |
184 begin |
184 begin |
185 x:= round(Gear.X) - Gear.Radius + 1; {*} |
185 x:= round(Gear.X) - Gear.Radius + 1; |
186 i:= x + Gear.Radius * 2 - 2; {*} |
186 i:= x + Gear.Radius * 2 - 2; |
187 repeat |
187 repeat |
188 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
188 if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0; |
189 inc(x) |
189 inc(x) |
190 until (x > i) or Result; |
190 until (x > i) or Result; |
191 end |
191 end |