fix merge
This commit is contained in:
parent
6e6a28c9ff
commit
34d2c82fd9
2 changed files with 48 additions and 49 deletions
|
@ -38,7 +38,7 @@ void RendererPolygon3d::setup() {
|
|||
addModel("../data/mesh/ship_ufo.stl", &m_shipModel);
|
||||
|
||||
m_texture = nullptr;
|
||||
m_backgroundTexturePath = "../data/img/stars_nebular.png";
|
||||
m_backgroundTexturePath = "../data/img/background_3.png";
|
||||
loadBackgroundTexture();
|
||||
|
||||
m_postprocess_shader.init();
|
||||
|
@ -520,7 +520,7 @@ void RendererPolygon3d::renderPlanets() {
|
|||
m_planetModel->render();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void RendererPolygon3d::renderSun() {
|
||||
m_planetModel->bind();
|
||||
|
||||
|
@ -546,7 +546,7 @@ void RendererPolygon3d::renderSun() {
|
|||
m_planetModel->render();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
void RendererPolygon3d::renderMissiles() {
|
||||
// TODO: add fire trail for missiles near the sun
|
||||
|
||||
|
@ -573,7 +573,7 @@ void RendererPolygon3d::renderMissiles() {
|
|||
glm::mat4 model = computeModelMatrix(ship);
|
||||
glUniformMatrix4fv(m_shader_game_objects.location("model"), 1, GL_FALSE, glm::value_ptr(model));
|
||||
|
||||
glm::vec3 c = glm::vec3(0.1, 1.0, 0.2);
|
||||
glm::vec3 c = ship->color;
|
||||
glUniform3f(m_shader_game_objects.location("materialColor"), c.x, c.y, c.z);
|
||||
|
||||
m_shipModel->render();
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace game {
|
|||
return false;
|
||||
}
|
||||
|
||||
Ship *ship = new Ship(generateId(), spawnPos, m_shipRadius);
|
||||
Ship *ship = new Ship(generateId(), spawnPos, player->color, m_shipRadius);
|
||||
player->ship = ship;
|
||||
ships.push_back(ship);
|
||||
|
||||
|
@ -159,29 +159,29 @@ namespace game {
|
|||
|
||||
void State::quitPlayer(size_t playerId)
|
||||
{
|
||||
std::cout << playerId << " quit" << std::endl;
|
||||
std::cout << playerId << " quit" << std::endl;
|
||||
|
||||
Player *player = playerForId(playerId);
|
||||
if (player != nullptr) {
|
||||
for (Missile *missile : player->missiles) {
|
||||
Player *player = playerForId(playerId);
|
||||
if (player != nullptr) {
|
||||
for (Missile *missile : player->missiles) {
|
||||
player->missiles.remove(missile);
|
||||
missile->player = nullptr;
|
||||
missile->player = nullptr;
|
||||
m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile));
|
||||
}
|
||||
|
||||
if (player->ship != nullptr) {
|
||||
ships.remove(player->ship);
|
||||
m_nextEvents.push_back(new ShipEvent(LifeCycle::Destroy, player->ship));
|
||||
}
|
||||
}
|
||||
|
||||
players.remove(player);
|
||||
players.remove(player);
|
||||
delete(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void State::clear(size_t playerId)
|
||||
{
|
||||
std::cout << playerId << " clear" << std::endl;
|
||||
std::cout << playerId << " clear" << std::endl;
|
||||
}
|
||||
|
||||
void State::setName(size_t playerId, std::string name)
|
||||
|
@ -234,9 +234,8 @@ namespace game {
|
|||
(void) dt;
|
||||
for (Player *player : players) {
|
||||
if (player->alive) {
|
||||
player->energy += dt;
|
||||
player->energy += dt * ENERGY_PER_DT;
|
||||
}
|
||||
|
||||
// try to execute as much queued commands as possible.
|
||||
while (player->hasCommandInQueue()) {
|
||||
Command *command = player->peekCommand();
|
||||
|
@ -261,7 +260,7 @@ namespace game {
|
|||
std::cout<<"player " << killer->id << " killed " << victim->id << std::endl;
|
||||
|
||||
// destroy ship
|
||||
ships.remove(victim->ship);
|
||||
ships.remove(victim->ship);
|
||||
|
||||
delete(victim->ship);
|
||||
victim->ship = nullptr;
|
||||
|
@ -282,7 +281,7 @@ namespace game {
|
|||
for (Player *player : players) {
|
||||
|
||||
std::vector<Missile*> rm;
|
||||
for (Missile *missile : player->missiles) {
|
||||
for (Missile *missile : player->missiles) {
|
||||
const Missile::Event evt = missile->advance(this, dt);
|
||||
const bool isHit = (evt.hit != Hit::Nothing);
|
||||
|
||||
|
@ -290,73 +289,73 @@ namespace game {
|
|||
missile->trace->addPointFromMissile(isHit); // force point if missile gets destroyed a
|
||||
}
|
||||
|
||||
if (!isHit) {
|
||||
continue;
|
||||
}
|
||||
if (!isHit) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool spawnExplosion = true;
|
||||
|
||||
switch(evt.hit) {
|
||||
case Hit::Planet:
|
||||
switch(evt.hit) {
|
||||
case Hit::Planet:
|
||||
// TODO: add black spot on the planet.
|
||||
// TODO: if water planet, add waves
|
||||
// TODO: if gas planet, add nice gas explosion effect
|
||||
// and start burning on this spot for some time.
|
||||
|
||||
//std::cout<<"hit Planet" << std::endl;
|
||||
break;
|
||||
//std::cout<<"hit Planet" << std::endl;
|
||||
break;
|
||||
|
||||
case Hit::Ship:
|
||||
//std::cout<<"hit Player" << std::endl;
|
||||
playerKillsPlayer(playerForId(evt.playerIdKiller), playerForId(evt.playerIdVictim));
|
||||
break;
|
||||
case Hit::Ship:
|
||||
//std::cout<<"hit Player" << std::endl;
|
||||
playerKillsPlayer(playerForId(evt.playerIdKiller), playerForId(evt.playerIdVictim));
|
||||
break;
|
||||
|
||||
case Hit::BorderOfUniverse:
|
||||
//std::cout<<"missile left the universe." << std::endl;
|
||||
case Hit::BorderOfUniverse:
|
||||
//std::cout<<"missile left the universe." << std::endl;
|
||||
spawnExplosion = false;
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (spawnExplosion) {
|
||||
addExplosionFromHit(&evt);
|
||||
}
|
||||
|
||||
if (missile->trace != nullptr) {
|
||||
missile->trace->finish();
|
||||
}
|
||||
if (missile->trace != nullptr) {
|
||||
missile->trace->finish();
|
||||
}
|
||||
|
||||
rm.push_back(missile);
|
||||
rm.push_back(missile);
|
||||
}
|
||||
|
||||
for (Missile *missile : rm) {
|
||||
player->missiles.remove(missile);
|
||||
for (Missile *missile : rm) {
|
||||
player->missiles.remove(missile);
|
||||
|
||||
m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void State::advanceExplosions(float dt)
|
||||
{
|
||||
std::vector<Explosion*> rm;
|
||||
std::vector<Explosion*> rm;
|
||||
|
||||
for (Explosion *explosion : explosions) {
|
||||
for (Explosion *explosion : explosions) {
|
||||
explosion->age += dt;
|
||||
if (explosion->age >= explosion->maxAge) {
|
||||
rm.push_back(explosion);
|
||||
rm.push_back(explosion);
|
||||
}
|
||||
}
|
||||
|
||||
for (Explosion *explosion : rm) {
|
||||
explosions.remove(explosion);
|
||||
for (Explosion *explosion : rm) {
|
||||
explosions.remove(explosion);
|
||||
|
||||
m_nextEvents.push_back(new ExplosionEvent(LifeCycle::Destroy, explosion));
|
||||
|
||||
//delete(explosion);
|
||||
}
|
||||
//delete(explosion);
|
||||
}
|
||||
}
|
||||
|
||||
void State::advance(float dt)
|
||||
|
|
Loading…
Reference in a new issue