mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Thargon.cpp
Go to the documentation of this file.
1 
6 #include "Thargon.h"
7 
8 Thargon::Thargon(float r, GLuint displayList, PlayerObject *player, float maxSpeed):ForeignSpaceShip(r,displayList)
9 {
10  this->player = player;
11  this->setShoot(false);
12  this->maxSpeed = maxSpeed;
13  this->setSpeed(0);
14 }
15 
17 {
18 }
19 
20 void Thargon::adjust( float t )
21 {
22  Vector3 playerPos = player->getPos();
23  Vector3 myPos = this->getPos();
24  Vector3 desiredView = playerPos - myPos;
25 
26  float distance = desiredView.length();
27 
28  if (distance < 100)
29  setSpeed(maxSpeed);
30  else
31  {
32  if (this->shipWasHitOnce())
33  setSpeed(10*maxSpeed);
34  else
35  setSpeed(0);
36  }
37 
38  desiredView.normalize();
39 
40  this->setView(desiredView);
41 }