57 void SpaceShip::initialize(
void ) {
61 m_backShieldPower = 100;
62 m_frontShieldPower = 100;
63 m_maxShieldPower = 100;
66 heatPunishTime = 1000;
70 m_shieldRecovers =
false;
71 m_ship_was_hit =
false;
88 Vector3 orthogonal = orgView * actView;
92 float angle = acos(projection) / ANGLE2DEG;
96 Plane * testplane =
new Plane(nullvector, orthogonal, orgView);
98 float testdistance = testplane->
distance(actView);
100 if (testdistance < 0)
103 glRotatef(angle,orthogonal.
x,orthogonal.
y,orthogonal.
z);
115 if( m_frontShieldPower < 0 || m_backShieldPower < 0 )
128 m_laserHeat -= time * m_maxLaserHeat/5000.0;
129 if( m_laserHeat < 0 )
131 if( heatPunishTime > 0)
132 heatPunishTime -= time;
134 m_overHeated =
false;
143 if ( shooting && !m_overHeated )
150 if( m_shieldRecovers ) {
151 this->recoverShieldBack( t );
152 this->recoverShieldFront( t );
166 return m_maxLaserHeat;
173 return m_laserHeat/m_maxLaserHeat;
180 return this->m_missiles;
196 void SpaceShip::useLaser( DWORD time ) {
197 m_laserHeat += time*6 * m_maxLaserHeat/5000.0;
198 if( m_laserHeat > m_maxLaserHeat ) {
199 m_laserHeat = m_maxLaserHeat;
201 heatPunishTime = 1000;
210 if( this->m_missiles > 0 )
216 return (shooting&&!m_overHeated);
231 return m_backShieldPower;
238 return m_backShieldPower / m_maxShieldPower;
245 return m_frontShieldPower;
252 return m_frontShieldPower / m_maxShieldPower;
271 if( m_backShieldPower >= 0 )
272 m_backShieldPower -= time*3* m_maxShieldPower/5000.0;
277 if( m_frontShieldPower >= 0 )
278 m_frontShieldPower -= time*3* m_maxShieldPower/5000.0;
281 void SpaceShip::recoverShieldBack( DWORD time ) {
282 m_backShieldPower += time*0.75 * m_maxShieldPower / 10000.0;
283 if( m_backShieldPower > m_maxShieldPower )
284 m_backShieldPower = m_maxShieldPower;
287 void SpaceShip::recoverShieldFront( DWORD time ) {
288 m_frontShieldPower += time*0.75 * m_maxShieldPower / 10000.0;
289 if( m_frontShieldPower > m_maxShieldPower )
290 m_frontShieldPower = m_maxShieldPower;
296 m_maxShieldPower = capacity;
297 if( m_frontShieldPower > m_maxShieldPower )
298 m_frontShieldPower = m_maxShieldPower;
299 if( m_backShieldPower > m_maxShieldPower )
300 m_backShieldPower = m_maxShieldPower;
304 m_shieldRecovers = recovers;
309 return m_ship_was_hit;