author | unc0rr |
Sat, 04 Jan 2014 23:55:54 +0400 | |
branch | webgl |
changeset 9950 | 2759212a27de |
parent 9521 | 8054d9d775fd |
parent 9706 | 5178d2263521 |
child 10015 | 4feced261c68 |
permissions | -rw-r--r-- |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
1 |
(* |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
9080 | 3 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
4 |
* |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
8 |
* |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
13 |
* |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
17 |
*) |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
18 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
20 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
21 |
unit uGearsHandlers; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
22 |
interface |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
23 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
24 |
uses uTypes; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
25 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
26 |
procedure cakeStep(Gear: PGear); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
27 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
28 |
implementation |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
29 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
30 |
uses SDLh, uFloat, uCollisions; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
31 |
|
7398 | 32 |
|
33 |
||
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
parents:
9080
diff
changeset
|
34 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
parents:
9080
diff
changeset
|
35 |
(x: 1; y: 0), |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
parents:
9080
diff
changeset
|
36 |
(x: 0; y: 1), |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
parents:
9080
diff
changeset
|
37 |
(x: -1; y: 0)); |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
38 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
39 |
procedure PrevAngle(Gear: PGear; dA: LongInt); inline; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
40 |
begin |
7721 | 41 |
Gear^.Angle := (LongInt(Gear^.Angle) - dA) and 3 |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
42 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
43 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
44 |
procedure NextAngle(Gear: PGear; dA: LongInt); inline; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
45 |
begin |
7721 | 46 |
Gear^.Angle := (LongInt(Gear^.Angle) + dA) and 3 |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
47 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
48 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
49 |
procedure cakeStep(Gear: PGear); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
50 |
var |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
51 |
xx, yy, xxn, yyn: LongInt; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
52 |
dA: LongInt; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
53 |
begin |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
54 |
dA := hwSign(Gear^.dX); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
55 |
xx := dirs[Gear^.Angle].x; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
56 |
yy := dirs[Gear^.Angle].y; |
7721 | 57 |
xxn := dirs[(LongInt(Gear^.Angle) + dA) and 3].x; |
58 |
yyn := dirs[(LongInt(Gear^.Angle) + dA) and 3].y; |
|
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
59 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
60 |
if (xx = 0) then |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
61 |
if TestCollisionYwithGear(Gear, yy) <> 0 then |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
62 |
PrevAngle(Gear, dA) |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
63 |
else |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
64 |
begin |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
65 |
Gear^.Tag := 0; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
66 |
Gear^.Y := Gear^.Y + int2hwFloat(yy); |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9080
diff
changeset
|
67 |
if TestCollisionXwithGear(Gear, xxn) = 0 then |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
68 |
begin |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
69 |
Gear^.X := Gear^.X + int2hwFloat(xxn); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
70 |
NextAngle(Gear, dA) |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
71 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
72 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
73 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
74 |
if (yy = 0) then |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9080
diff
changeset
|
75 |
if TestCollisionXwithGear(Gear, xx) <> 0 then |
7370
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
76 |
PrevAngle(Gear, dA) |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
77 |
else |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
78 |
begin |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
79 |
Gear^.Tag := 0; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
80 |
Gear^.X := Gear^.X + int2hwFloat(xx); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
81 |
if TestCollisionYwithGear(Gear, yyn) = 0 then |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
82 |
begin |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
83 |
Gear^.Y := Gear^.Y + int2hwFloat(yyn); |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
84 |
NextAngle(Gear, dA) |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
85 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
86 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
87 |
end; |
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
88 |
|
d50b874e7ee8
Introduce uGearsHandlers.pas, for now only part of cake handlers is moved there
unc0rr
parents:
diff
changeset
|
89 |
end. |