Debian Codegraph @

src/movement.cpp

raw symbols SCIP
1 /***************************************************************************
2 movement.cpp - description
3 -------------------
4 begin : may 16th, 2004
5 copyright : (C) 2004-2007 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: movement.cpp 375 2008-10-28 14:47:15Z neoneurone $
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * any later version. *
17 * *
18 ***************************************************************************/
19
20 // Useful enumerations
21 #include "opencity_direction.h"
22
23 // OpenCity header
24 #include "movement.h"
25
26
27 /*=====================================================================*/
28 Movement::Movement():
29 _fRY( 0 ), _fRX( 0 ), _fRZ( 0 ),
30 _fTX( 0 ), _fTY( 0 ), _fTZ( 0 ),
31 _eDir( OC_DIR_O_S )
32 {
33 OPENCITY_DEBUG("ctor");
34 }
35
36
37 /*=====================================================================*/
38 Movement::~Movement()
39 {
40 OPENCITY_DEBUG("dtor");
41 }
42
43
44 /*=====================================================================*/
45 void
46 Movement::SetPath(
47 vector<Destination> newPath )
48 {
49 // WARNING: Destination must not use pointers
50 this->vdest = newPath;
51 }
52
53
54 /*=====================================================================*/
55 const OPENCITY_GRAPHIC_CODE &
56 Movement::GetGraphicCode() const
57 {
58 return _eGC;
59 }
60
61
62 /*=====================================================================*/
63 void
64 Movement::SetAngle( const Destination & rD )
65 {
66 _eDir = rD._eDir;
67
68 switch (_eDir) {
69 case OC_DIR_O_N:
70 _fRY = 180;
71 _fTX = 1; _fTY = 0; _fTZ = 1;
72 break;
73
74 case OC_DIR_O_E:
75 _fRY = 90;
76 _fTX = 0; _fTY = 0; _fTZ = 1;
77 break;
78
79 case OC_DIR_O_S:
80 _fRY = 0;
81 _fTX = 0; _fTY = 0; _fTZ = 0;
82 break;
83
84 case OC_DIR_O_W:
85 _fRY = -90;
86 _fTX = 1; _fTY = 0; _fTZ = 0;
87 break;
88
89 case OC_DIR_S_E:
90 case OC_DIR_S_W:
91 case OC_DIR_N_W:
92 case OC_DIR_N_E:
93 default:
94 OPENCITY_DEBUG( "Game design error" );
95 assert( 0 );
96 break;
97 }
98 }
99
100
101 /*=====================================================================*/
102 void
103 Movement::SetSlope(
104 const Destination & rcA,
105 const Destination & rcB )
106 {
107 static int sign;
108
109 if (rcA._iHMin != rcA._iHMax) {
110 if (rcA._iHMin > rcB._iHMin) {
111 sign = 1;
112 }
113 else if (rcB._iHMin != rcB._iHMax) {
114 sign = -1;
115 }
116 else
117 sign = 0;
118
119 switch (_eDir) {
120 case OC_DIR_O_N:
121 case OC_DIR_O_S:
122 _fRX = 0; _fRZ = 45;
123 break;
124
125 case OC_DIR_O_E:
126 case OC_DIR_O_W:
127 _fRX = sign * 45; _fRZ = 0;
128 break;
129
130 case OC_DIR_S_E:
131 case OC_DIR_S_W:
132 case OC_DIR_N_W:
133 case OC_DIR_N_E:
134 default:
135 OPENCITY_DEBUG( "Game design error" );
136 assert( 0 );
137 break;
138 }
139 }
140 else {
141 _fRX = 0; _fRZ = 0;
142 }
143 }
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180