From 8ec3f4727630f5b294364363b7be680255d49b6b Mon Sep 17 00:00:00 2001 From: Andreas Ortmann Date: Wed, 5 Oct 2016 23:37:27 +0200 Subject: [PATCH 1/2] removed debug/info statements. --- game/developer_console.cpp | 4 ++-- game/renderer_polygon_3d/image_texture.cpp | 20 ++++++++-------- .../renderer_polygon_3d.cpp | 24 +++++++------------ 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/game/developer_console.cpp b/game/developer_console.cpp index 263ed86..046e7e4 100644 --- a/game/developer_console.cpp +++ b/game/developer_console.cpp @@ -49,8 +49,8 @@ namespace developer { return false; } - std::cout<<"[developer console] adding developer " - "callback for token '" << token << "'" << std::endl; + //std::cout<<"[developer console] adding developer " + // "callback for token '" << token << "'" << std::endl; m_callbacks[token] = cb; diff --git a/game/renderer_polygon_3d/image_texture.cpp b/game/renderer_polygon_3d/image_texture.cpp index bacaee5..6c71f88 100644 --- a/game/renderer_polygon_3d/image_texture.cpp +++ b/game/renderer_polygon_3d/image_texture.cpp @@ -78,11 +78,11 @@ namespace endofthejedi { NULL, NULL, NULL); - if (color_type == PNG_COLOR_TYPE_RGB) { - puts("PNG_COLOR_TYPE_RGB"); - } else if (color_type == PNG_COLOR_TYPE_RGBA) { - puts("PNG_COLOR_TYPE_RGBA"); - } + //if (color_type == PNG_COLOR_TYPE_RGB) { + // puts("PNG_COLOR_TYPE_RGB"); + //} else if (color_type == PNG_COLOR_TYPE_RGBA) { + // puts("PNG_COLOR_TYPE_RGBA"); + //} //update width and height based on png info @@ -95,11 +95,11 @@ namespace endofthejedi { m_size = glm::vec2(); - puts("#########################################"); - printf("# PNG: width=%d, height=%d\n", twidth, theight); - printf("# powers of two: w=%d, h=%d\n", pot_width, pot_height); - printf("# uv scale two: x=%f, y=%f\n", m_uvScale.x, m_uvScale.y); - puts("#########################################"); + //puts("#########################################"); + //printf("# PNG: width=%d, height=%d\n", twidth, theight); + //printf("# powers of two: w=%d, h=%d\n", pot_width, pot_height); + //printf("# uv scale two: x=%f, y=%f\n", m_uvScale.x, m_uvScale.y); + //puts("#########################################"); // Update the png info struct. png_read_update_info(png_ptr, info_ptr); diff --git a/game/renderer_polygon_3d/renderer_polygon_3d.cpp b/game/renderer_polygon_3d/renderer_polygon_3d.cpp index 9104b51..f21b868 100644 --- a/game/renderer_polygon_3d/renderer_polygon_3d.cpp +++ b/game/renderer_polygon_3d/renderer_polygon_3d.cpp @@ -38,7 +38,8 @@ void RendererPolygon3d::setup() { addModel("../data/mesh/ship_ufo.stl", &m_shipModel); m_texture = nullptr; - m_backgroundTexturePath = "../data/img/background_3.png"; + //m_backgroundTexturePath = "../data/img/background_3.png"; + m_backgroundTexturePath = "../data/img/stars_nebular.png"; loadBackgroundTexture(); m_postprocess_shader.init(); @@ -86,15 +87,15 @@ void RendererPolygon3d::loadBackgroundTexture() { glActiveTexture(GL_TEXTURE0); m_texture->loadPng(); - std::cout << "texture loading: " << m_texture->valid() << std::endl; + //std::cout << "texture loading: " << m_texture->valid() << std::endl; if (!m_texture->valid()) { std::cout << "loading failed!"; return; // exit(-1); } - glm::vec2 s = m_texture->size(); - std::cout << "texture size is " << s.x << " X " << s.y << std::endl; + //glm::vec2 s = m_texture->size(); + //std::cout << "texture size is " << s.x << " X " << s.y << std::endl; } void RendererPolygon3d::renderBackgroundImage() { @@ -252,6 +253,9 @@ void RendererPolygon3d::addExplosionEffect(size_t id, const glm::vec2 &missileVelocity, bool isPlanetHit, size_t n, float duration) { + + (void) missileVelocity; + // float particleRadius = 0.005; // float particleRadius = 0.003; float particleRadius = 0.02; @@ -586,18 +590,8 @@ void RendererPolygon3d::renderShips() { void RendererPolygon3d::addModel(const std::string &filename, PolygonModel **dest) { + // std::cout<<"adding a model: " << filename << std::endl; - - *dest = new PolygonModel(filename); - if (!(*dest)->import()) { - std::cout << "error: failed to load needed model!!!" << std::endl - << std::endl; - exit(-1); - } - - (*dest)->setup(&m_shader_game_objects); - (*dest)->uploadToOpenGl(); - *dest = new PolygonModel(filename); if (!(*dest)->import()) { std::cout << "error: failed to load needed model!!!" << std::endl From dc5cc897927ba3bf70d4ba91d319a6fc4bb23c59 Mon Sep 17 00:00:00 2001 From: Andreas Ortmann Date: Wed, 5 Oct 2016 23:53:22 +0200 Subject: [PATCH 2/2] added player ship delete event and for missiles too. --- game/state/state.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/game/state/state.cpp b/game/state/state.cpp index af4a2f7..daecb33 100644 --- a/game/state/state.cpp +++ b/game/state/state.cpp @@ -165,9 +165,16 @@ namespace game { if (player != nullptr) { for (Missile *missile : player->missiles) { 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); + delete(player); } } @@ -534,6 +541,16 @@ namespace game { } break; + case EventType::Ship: + { + auto *se = static_cast(evt); + //std::cout<<"got missile delete event, finally deleting missile #" + // << me->object()->id << std::endl; + + delete(se->object()); + } + break; + case EventType::Missile: { auto *me = static_cast(evt);