-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAirplaneEnemy.cpp
41 lines (35 loc) · 1.09 KB
/
AirplaneEnemy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Enemy.h"
#include "AirplaneEnemy.h"
AirplaneEnemy::AirplaneEnemy(Game * game, Ogre::SceneNode * sceneNode, const AirplaneState& state, Ogre::String name) :
Enemy(game), airplane(new Airplane(game, sceneNode, state))
{
Ogre::SceneManager * sceneManager = sceneNode->getCreator();
Ogre::Entity * entity = sceneManager->createEntity(name, "sphere.mesh");
entity->setMaterialName("Enemy_Material");
sceneNode->scale(25.0f, 25.0f, 25.0f);
sceneNode->attachObject(entity);
}
void AirplaneEnemy::update(Airplane * player, float dt) {
if(posBelow(player->getPosition())){
airplane->pitchDown();
}else{
airplane->pitchUp();
}
bool playerLeft = posLeft(player->getPosition());
if(playerLeft){
airplane->yawLeft();
}else{
airplane->yawRight();
}
if(!posInFront(player->getPosition())){
airplane->decreaseThrust();
if(playerLeft){
airplane->rollRight();
}
else{
airplane->rollLeft();
}
}
airplane->update(dt);
}
AirplaneEnemy::~AirplaneEnemy() { }