revert commit
This commit is contained in:
@@ -28,9 +28,7 @@ Enemy::Enemy(const std::string &fileName,
|
|||||||
hasTarget = false;
|
hasTarget = false;
|
||||||
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound(fileMusic.c_str(), false);
|
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound(fileMusic.c_str(), false);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
||||||
canAttack = false;
|
attack = false;
|
||||||
lastAttacked = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,17 +80,6 @@ void Enemy::collide(const Entity * entity)
|
|||||||
position.z = difference.z + entity->position.z;
|
position.z = difference.z + entity->position.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Enemy::attack()
|
|
||||||
{
|
|
||||||
float timeNow = glutGet(GLUT_ELAPSED_TIME)/1000.0f;
|
|
||||||
if (canAttack && timeNow - lastAttacked > 0.8)
|
|
||||||
{
|
|
||||||
lastAttacked = timeNow;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Enemy::update(float delta)
|
void Enemy::update(float delta)
|
||||||
{
|
{
|
||||||
music->SetPos(position, Vec3f());
|
music->SetPos(position, Vec3f());
|
||||||
@@ -112,7 +99,7 @@ void Enemy::update(float delta)
|
|||||||
length = sqrt(dx*dx + dz*dz);
|
length = sqrt(dx*dx + dz*dz);
|
||||||
if (length > 1)
|
if (length > 1)
|
||||||
{
|
{
|
||||||
canAttack = false;
|
attack = false;
|
||||||
|
|
||||||
dx /= length;
|
dx /= length;
|
||||||
dz /= length;
|
dz /= length;
|
||||||
@@ -125,7 +112,7 @@ void Enemy::update(float delta)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
canAttack = true;
|
attack = true;
|
||||||
}
|
}
|
||||||
rotation.y = atan2f(dx, dz) * 180 / M_PI;
|
rotation.y = atan2f(dx, dz) * 180 / M_PI;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ public:
|
|||||||
float health;
|
float health;
|
||||||
float damage;
|
float damage;
|
||||||
int xp;
|
int xp;
|
||||||
bool canAttack;
|
bool attack;
|
||||||
float lastAttacked;
|
|
||||||
bool attack();
|
|
||||||
|
|
||||||
void update(float);
|
void update(float);
|
||||||
void draw();
|
void draw();
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void configureOpenGL()
|
|||||||
//Init window and glut display mode
|
//Init window and glut display mode
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
glutInitWindowSize(1440, 900);
|
glutInitWindowSize(1440, 900);
|
||||||
//glutPositionWindow((glutGet(GLUT_SCREEN_WIDTH) / 2) - (glutGet(GLUT_WINDOW_WIDTH) / 2), (glutGet(GLUT_SCREEN_HEIGHT) / 2) - (glutGet(GLUT_WINDOW_HEIGHT) / 2));
|
//glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH) / 2) - (glutGet(GLUT_WINDOW_WIDTH) / 2), (glutGet(GLUT_SCREEN_HEIGHT) / 2) - (glutGet(GLUT_WINDOW_HEIGHT) / 2));
|
||||||
|
|
||||||
glutCreateWindow("Crystal Point");
|
glutCreateWindow("Crystal Point");
|
||||||
//glutFullScreen();
|
//glutFullScreen();
|
||||||
|
|||||||
@@ -334,9 +334,10 @@ void World::update(float elapsedTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enemy->attack())
|
if (enemy->attack)
|
||||||
{
|
{
|
||||||
player->HpDown(enemy->damage);
|
remove = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user