From 6df660719ee92acd9fa31e1fa79867431761bacb Mon Sep 17 00:00:00 2001 From: qqii Date: Thu, 15 Mar 2018 22:39:32 +0000 Subject: [PATCH 1/7] Move creating of button groups into a function --- src/server/main.cpp | 94 ++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/src/server/main.cpp b/src/server/main.cpp index 3fac4d56..2229239c 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -30,6 +30,55 @@ #define PLAYER_DELTA 100 // Delta around a beat a player can hit (millisecs) #define TIME 60000000.f / BPM // Time between beats (microsecs) +namespace tempo +{ +void loadTiles(anax::World &world) +{ + std::vector wall = {{37, 17}, {38, 17}, {39, 17}, {40, 17}, {41, 17}, + {42, 17}, {43, 17}, {44, 17}, {45, 17}}; + tempo::createButtonGroup(world, {{40, 12}}, wall); + + std::vector wall1 = { + {37, 48}, {38, 48}, {39, 48}, {40, 48}, {41, 48}, {42, 48}, {43, 48}, {44, 48}, + }; + tempo::createButtonGroup(world, {{40, 43}, {44, 43}, {36, 43}}, wall1); + + std::vector wall2 = {{36, 62}, {36, 63}, {36, 64}, {36, 65}, {36, 66}, + {36, 67}, {36, 68}, {50, 62}, {50, 63}, {50, 64}, + {50, 65}, {50, 66}, {50, 67}, {50, 68}}; + tempo::createButtonGroup(world, {{40, 65}}, wall2); + + std::vector wall3 = {{37, 69}, {38, 69}, {39, 69}, {40, 69}, + {41, 69}, {42, 69}, {43, 69}}; + tempo::createButtonGroup(world, {{66, 70}, {13, 69}}, wall3); + + std::vector wall4 = {{40, 132}, {41, 132}, {42, 132}}; + tempo::createButtonGroup(world, {{41, 110}, {26, 128}, {57, 128}}, wall4); + // int width, height, components; + + // uint8_t *pixel_data = (uint8_t *)stbi_load(stage_file, &width, &height, &components, 4); + // if (pixel_data == NULL || width < 0 || height < 0 || components < 0) { + // printf("Failed to load level '%s', pixels: %p, width: %i, height: %i, components: %i\n", + // stage_file, pixel_data, width, height, components); + // return; + //} + + //// Load the new tiles + // for (int y = 0; y < height; y++) { + // int base = width * y * 4; + // for (int x = 0; x < width; x++) { + // uint8_t *pixel = &pixel_data[base + x * 4]; + + // if (pixel[0] > 0) { + // int height = (int)(pixel[0] - 127) / 25.6; + // _global_stage.push_back(stage_tile(glm::ivec2(y, x), (float)height)); + // } + // } + //} + // stbi_image_free(pixel_data); +} +} // namespace tempo + int main(int argc, const char **argv) { tempo::Song mainsong("resources/sound/ravecave_loop.ogg"); @@ -50,12 +99,12 @@ int main(int argc, const char **argv) anax::World world; // Create Systems - server::SystemAI system_ai; + server::SystemAI system_ai; server::SystemAttack system_attack(world); - server::SystemCombo system_combo; + server::SystemCombo system_combo; server::SystemMovement system_movement; - tempo::SystemHealth system_health; - tempo::SystemTrigger system_trigger(world); + tempo::SystemHealth system_health; + tempo::SystemTrigger system_trigger(world); world.addSystem(system_ai); world.addSystem(system_attack); @@ -66,44 +115,26 @@ int main(int argc, const char **argv) world.refresh(); // Create some Test Entities - + tempo::createMobStill(world, glm::ivec2(36, 42)); tempo::createMobStill(world, glm::ivec2(40, 42)); tempo::createMobStill(world, glm::ivec2(44, 42)); - + tempo::createMobCreeper(world, glm::ivec2(40, 64)); - std::deque path {glm::ivec2(64, 68), - glm::ivec2(64, 72), - glm::ivec2(68, 72), - glm::ivec2(68, 68)}; + std::deque path{glm::ivec2(64, 68), glm::ivec2(64, 72), glm::ivec2(68, 72), + glm::ivec2(68, 68)}; tempo::createMobPatroller(world, path[0], path); - std::deque path2 {glm::ivec2(11, 67), - glm::ivec2(11, 73), - glm::ivec2(15, 73), - glm::ivec2(15, 67)}; + std::deque path2{glm::ivec2(11, 67), glm::ivec2(11, 73), glm::ivec2(15, 73), + glm::ivec2(15, 67)}; tempo::createMobPatroller(world, path2[0], path2); - + // tempo::createMobCreeper(world, glm::ivec2(12, 12)); // tempo::createMobCreeper(world, glm::ivec2(14, 14)); // tempo::createMobAntiSnail(world, glm::ivec2(4, 4)); - std::vector wall = {{37,17},{38,17},{39,17},{40,17},{41,17},{42,17},{43,17},{44,17}, {45,17}}; - tempo::createButtonGroup(world, {{40, 12}}, wall); - - std::vector wall1 = {{37,48},{38,48},{39,48},{40,48},{41,48},{42,48},{43,48},{44,48},}; - tempo::createButtonGroup(world, {{40, 43},{44,43},{36,43}}, wall1); - - std::vector wall2 = {{36,62},{36,63},{36,64},{36,65},{36,66},{36,67},{36,68}, - {50,62},{50,63},{50,64},{50,65},{50,66},{50,67},{50,68}}; - tempo::createButtonGroup(world, {{40, 65}}, wall2); - - std::vector wall3 = {{37,69},{38,69},{39,69},{40,69},{41,69},{42,69},{43,69}}; - tempo::createButtonGroup(world, {{66,70},{13,69}}, wall3); - - std::vector wall4 = {{40,132},{41,132},{42,132}}; - tempo::createButtonGroup(world, {{41,110},{26,128},{57,128}}, wall4); + tempo::loadTiles(world); world.refresh(); @@ -142,8 +173,7 @@ int main(int argc, const char **argv) system_health.broadcastHealth(); } - if (clock.passed_antibeat()) - { + if (clock.passed_antibeat()) { } //////////////// From 4875a58d590d70934bcaec64bc86603cb18a6cd0 Mon Sep 17 00:00:00 2001 From: qqii Date: Thu, 15 Mar 2018 23:35:41 +0000 Subject: [PATCH 2/7] Loading function and Tile->Button --- bin/resources/levels/levelTest_buttons.bmp | Bin 0 -> 16346 bytes .../tempo/component/ComponentStage.hpp | 2 + .../src/component/ComponentStage.cpp | 96 +++++++++++++++++- src/server/main.cpp | 51 +--------- 4 files changed, 97 insertions(+), 52 deletions(-) create mode 100644 bin/resources/levels/levelTest_buttons.bmp diff --git a/bin/resources/levels/levelTest_buttons.bmp b/bin/resources/levels/levelTest_buttons.bmp new file mode 100644 index 0000000000000000000000000000000000000000..28c76401cce0c11027ef31b76bbc7cfc98e41bba GIT binary patch literal 16346 zcmeI11C%386otRFZQHgrYumPMW^LQHZQHhO+xe4BCtY3B8JyYK$)3OaoTT2n_1>*p zw>y10iCgLG`LG>50z)fHG}-cMWO)T3xDBtD3nGPbe_2551a3tubhJ(S;4Pp|ZGZp) z2pBL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U=4Amknhk|QCrO_j!4H0PVta|Nc`=l}o zZ9=FPX*m>J3;KyJT~qDXibaN2f}zV~Ry=Sr=uYc`P6%{h?KyD23_MVJ0JKE9)4HIx z&$CQ!wuAS4I}t*?jYZBapl9v&mCarhX{P_CE@3~8(7wLBH#@Eot904t93;xK zxtzv3US!gkcqtf-dvX2<>7FU!YX z6(dCU_5DqkphXOQqsy`vuMRyk%xaV9mWo>SiA8#Py&zV}^dqP3%57U%QYG*&T{caE zBKJ_zr3kkUVyRgv(|}5WeNJU^8tJu*%LuW`A%Gr2``UWM_BoZwX{6WgVJ&w+<#1A9 zgB@$@6bTl48S1nAL=ssayf6e`&8Fo6XvZQIIb`2HoVpGcZxK+Tu9kJ zqDy)@`#a}MZxzWeLzkXO0%rInnBk4^U-3)(6y%MK`B91Fm#fGUpRY~MzT^3kC7#ln iMZ;XiEsJDPm=B&hJ>BddnG_#I{|KQ$VmR=BcHlpOm)my$ literal 0 HcmV?d00001 diff --git a/src/lib-tempo/include/tempo/component/ComponentStage.hpp b/src/lib-tempo/include/tempo/component/ComponentStage.hpp index b39cf08e..00678779 100644 --- a/src/lib-tempo/include/tempo/component/ComponentStage.hpp +++ b/src/lib-tempo/include/tempo/component/ComponentStage.hpp @@ -68,6 +68,8 @@ struct ComponentStage ComponentID getId(); }; +void loadButtons(anax::World &world, const char *tile_map); + } // namespace tempo #endif diff --git a/src/lib-tempo/src/component/ComponentStage.cpp b/src/lib-tempo/src/component/ComponentStage.cpp index 9df35047..5d056c0d 100644 --- a/src/lib-tempo/src/component/ComponentStage.cpp +++ b/src/lib-tempo/src/component/ComponentStage.cpp @@ -1,17 +1,22 @@ #include +#include #include +#include + #define STB_IMAGE_IMPLEMENTATION #include #include #include #include +#include + +#include namespace tempo { - std::vector _global_stage; std::string _global_stage_loaded("None"); @@ -51,7 +56,7 @@ void ComponentStage::loadLevel(const char *stage_file) } } } - tiles = &_global_stage; + tiles = &_global_stage; _global_stage_loaded = std::string(stage_file); stbi_image_free(pixel_data); @@ -132,4 +137,91 @@ sf::Packet ComponentStage::dumpComponent() return p; } + +void fake_createButtonGroup(anax::World & world, + std::vector positions, + std::vector tiles) +{ + std::cout << "positions = {"; + for (int i = 0; i < positions.size() - 1; i++) { + std::cout << glm::to_string(positions[i]) << ","; + } + std::cout << glm::to_string(positions.back()) << "}" << std::endl; + + std::cout << "tiles = {"; + for (int i = 0; i < tiles.size() - 1; i++) { + std::cout << glm::to_string(tiles[i]) << ","; + } + std::cout << glm::to_string(tiles.back()) << "}" << std::endl; +} + +void loadButtons(anax::World &world, const char *tile_map) +{ + std::vector wall0 = {{37, 17}, {38, 17}, {39, 17}, {40, 17}, {41, 17}, + {42, 17}, {43, 17}, {44, 17}, {45, 17}}; + createButtonGroup(world, {{40, 12}}, wall0); + + std::vector wall1 = { + {37, 48}, {38, 48}, {39, 48}, {40, 48}, {41, 48}, {42, 48}, {43, 48}, {44, 48}, + }; + createButtonGroup(world, {{40, 43}, {44, 43}, {36, 43}}, wall1); + + std::vector wall2 = {{36, 62}, {36, 63}, {36, 64}, {36, 65}, {36, 66}, + {36, 67}, {36, 68}, {50, 62}, {50, 63}, {50, 64}, + {50, 65}, {50, 66}, {50, 67}, {50, 68}}; + createButtonGroup(world, {{40, 65}}, wall2); + + std::vector wall3 = {{37, 69}, {38, 69}, {39, 69}, {40, 69}, + {41, 69}, {42, 69}, {43, 69}}; + createButtonGroup(world, {{66, 70}, {13, 69}}, wall3); + + std::vector wall4 = {{40, 132}, {41, 132}, {42, 132}}; + createButtonGroup(world, {{41, 110}, {26, 128}, {57, 128}}, wall4); + + int width, height, components; + + uint8_t *pixel_data = (uint8_t *) stbi_load(tile_map, &width, &height, &components, 4); + if (pixel_data == NULL || width < 0 || height < 0 || components < 0) { + printf("Failed to load level '%s', pixels: %p, width: %i, height: %i, components: %i\n", + tile_map, pixel_data, width, height, components); + return; + } + + std::vector> tiles(256); + std::vector> wall(256); + + // Load the new tiles + for (int y = 0; y < height; y++) { + int base = width * y * 4; + for (int x = 0; x < width; x++) { + uint8_t *pixel = &pixel_data[base + x * 4]; + + uint8_t r = pixel[0]; + uint8_t g = pixel[1]; + uint8_t b = pixel[2]; + + if (b == 0) { + // this is a tile + // r = index + // g = height + tiles[r].push_back(glm::ivec2(y, x)); + } else if (b == 0) { + // this is a wall + // g = index + // b = height + wall[g].push_back(glm::ivec2(y, x)); + } + } + } + stbi_image_free(pixel_data); + + for (int i = 0; i < 265; i++) { + if (tiles[i].empty() || wall[i].empty()) { + continue; + } + + fake_createButtonGroup(world, tiles[i], wall[i]); + } +} + } // namespace tempo diff --git a/src/server/main.cpp b/src/server/main.cpp index 2229239c..da7bf1bf 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -30,55 +30,6 @@ #define PLAYER_DELTA 100 // Delta around a beat a player can hit (millisecs) #define TIME 60000000.f / BPM // Time between beats (microsecs) -namespace tempo -{ -void loadTiles(anax::World &world) -{ - std::vector wall = {{37, 17}, {38, 17}, {39, 17}, {40, 17}, {41, 17}, - {42, 17}, {43, 17}, {44, 17}, {45, 17}}; - tempo::createButtonGroup(world, {{40, 12}}, wall); - - std::vector wall1 = { - {37, 48}, {38, 48}, {39, 48}, {40, 48}, {41, 48}, {42, 48}, {43, 48}, {44, 48}, - }; - tempo::createButtonGroup(world, {{40, 43}, {44, 43}, {36, 43}}, wall1); - - std::vector wall2 = {{36, 62}, {36, 63}, {36, 64}, {36, 65}, {36, 66}, - {36, 67}, {36, 68}, {50, 62}, {50, 63}, {50, 64}, - {50, 65}, {50, 66}, {50, 67}, {50, 68}}; - tempo::createButtonGroup(world, {{40, 65}}, wall2); - - std::vector wall3 = {{37, 69}, {38, 69}, {39, 69}, {40, 69}, - {41, 69}, {42, 69}, {43, 69}}; - tempo::createButtonGroup(world, {{66, 70}, {13, 69}}, wall3); - - std::vector wall4 = {{40, 132}, {41, 132}, {42, 132}}; - tempo::createButtonGroup(world, {{41, 110}, {26, 128}, {57, 128}}, wall4); - // int width, height, components; - - // uint8_t *pixel_data = (uint8_t *)stbi_load(stage_file, &width, &height, &components, 4); - // if (pixel_data == NULL || width < 0 || height < 0 || components < 0) { - // printf("Failed to load level '%s', pixels: %p, width: %i, height: %i, components: %i\n", - // stage_file, pixel_data, width, height, components); - // return; - //} - - //// Load the new tiles - // for (int y = 0; y < height; y++) { - // int base = width * y * 4; - // for (int x = 0; x < width; x++) { - // uint8_t *pixel = &pixel_data[base + x * 4]; - - // if (pixel[0] > 0) { - // int height = (int)(pixel[0] - 127) / 25.6; - // _global_stage.push_back(stage_tile(glm::ivec2(y, x), (float)height)); - // } - // } - //} - // stbi_image_free(pixel_data); -} -} // namespace tempo - int main(int argc, const char **argv) { tempo::Song mainsong("resources/sound/ravecave_loop.ogg"); @@ -134,7 +85,7 @@ int main(int argc, const char **argv) // tempo::createMobCreeper(world, glm::ivec2(14, 14)); // tempo::createMobAntiSnail(world, glm::ivec2(4, 4)); - tempo::loadTiles(world); + tempo::loadButtons(world, "levelTest_buttons.bmp"); world.refresh(); From 5de58c66977c6306cdb8b0c69d461c85e136b8af Mon Sep 17 00:00:00 2001 From: qqii Date: Fri, 16 Mar 2018 00:14:23 +0000 Subject: [PATCH 3/7] Filesystem is broken --- bin/resources/levels/levelTest_buttons.bmp | Bin 16346 -> 45322 bytes .../src/component/ComponentStage.cpp | 18 +++++++++--------- src/lib-tempo/src/song.cpp | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/resources/levels/levelTest_buttons.bmp b/bin/resources/levels/levelTest_buttons.bmp index 28c76401cce0c11027ef31b76bbc7cfc98e41bba..7c14d12c465528626ec1e5e75b0cfabf1b1cf6ad 100644 GIT binary patch delta 196 zcmcar-}Q*e%E^~&BLf&z0m&R7o(9AzK+MP>0VEk1CTw6}5axzpumF&7at|t=+{j`u zF-v6g1eQ7c_=uTYlLK|cU@A^9LwV~Mp^O!bZ2$i=01=cwjZp}~M<$VtfLb?s0?R@G D&iX(o literal 16346 zcmeI11C%386otRFZQHgrYumPMW^LQHZ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< zx~w+{>!Gn)NfZWQ%7)0f1=MRdEA8%s+T?(3kRy{g6kLzkeqU87-4QvrQ0TRr)g`Tw z&?Sayk(NWjwV=|d%n39$M9wXsUb|UoR|cU=4Amknhk|QCrO_j!4H0PVta|Nc`=l}o zZ9=FPX*m>J3;KyJT~qDXibaN2f}zV~Ry=Sr=uYc`P6%{h?KyD23_MVJ0JKE9)4HIx z&$CQ!wuAS4I}t*?jYZBapl9v&mCarhX{P_CE@3~8(7wLBH#@Eot904t93;xK zxtzv3US!gkcqtf-dvX2<>7FU!YX z6(dCU_5DqkphXOQqsy`vuMRyk%xaV9mWo>SiA8#Py&zV}^dqP3%57U%QYG*&T{caE zBKJ_zr3kkUVyRgv(|}5WeNJU^8tJu*%LuW`A%Gr2``UWM_BoZwX{6WgVJ&w+<#1A9 zgB@$@6bTl48S1nAL=ssayf6e`&8Fo6XvZQIIb`2HoVpGcZxK+Tu9kJ zqDy)@`#a}MZxzWeLzkXO0%rInnBk4^U-3)(6y%MK`B91Fm#fGUpRY~MzT^3kC7#ln iMZ;XiEsJDPm=B&hJ>BddnG_#I{|KQ$VmR=BcHlpOm)my$ diff --git a/src/lib-tempo/src/component/ComponentStage.cpp b/src/lib-tempo/src/component/ComponentStage.cpp index 5d056c0d..d245ec5e 100644 --- a/src/lib-tempo/src/component/ComponentStage.cpp +++ b/src/lib-tempo/src/component/ComponentStage.cpp @@ -187,8 +187,8 @@ void loadButtons(anax::World &world, const char *tile_map) return; } - std::vector> tiles(256); - std::vector> wall(256); + std::vector> buttons(256); + std::vector> walls(256); // Load the new tiles for (int y = 0; y < height; y++) { @@ -200,27 +200,27 @@ void loadButtons(anax::World &world, const char *tile_map) uint8_t g = pixel[1]; uint8_t b = pixel[2]; - if (b == 0) { - // this is a tile + if (b == 0 && r != 0) { + // this is a button // r = index // g = height - tiles[r].push_back(glm::ivec2(y, x)); - } else if (b == 0) { + buttons[r].push_back(glm::ivec2(y, x)); + } else if (r == 0 && g != 0) { // this is a wall // g = index // b = height - wall[g].push_back(glm::ivec2(y, x)); + walls[g].push_back(glm::ivec2(y, x)); } } } stbi_image_free(pixel_data); for (int i = 0; i < 265; i++) { - if (tiles[i].empty() || wall[i].empty()) { + if (buttons[i].empty() || walls[i].empty()) { continue; } - fake_createButtonGroup(world, tiles[i], wall[i]); + fake_createButtonGroup(world, buttons[i], walls[i]); } } diff --git a/src/lib-tempo/src/song.cpp b/src/lib-tempo/src/song.cpp index a4027237..2a247f11 100644 --- a/src/lib-tempo/src/song.cpp +++ b/src/lib-tempo/src/song.cpp @@ -10,6 +10,7 @@ Song::Song(std::string path) void Song::start() { + //sound.setLoop(true); sound.play(); } From 1d9ae6d61e151946386b56de02156b4a5e087ef9 Mon Sep 17 00:00:00 2001 From: qqii Date: Fri, 16 Mar 2018 00:23:57 +0000 Subject: [PATCH 4/7] Working button loader with 2 groups Currently still prints loaded --- bin/resources/levels/levelTest_buttons.bmp | Bin 45322 -> 45322 bytes .../src/component/ComponentStage.cpp | 3 ++- src/server/main.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/resources/levels/levelTest_buttons.bmp b/bin/resources/levels/levelTest_buttons.bmp index 7c14d12c465528626ec1e5e75b0cfabf1b1cf6ad..6f852df1693df4a7055cbe0d65f5bd4822c5ba07 100644 GIT binary patch delta 65 zcmeBr#MJeOX+wJ<)4zWk3pa3W-k))V5lHM~oSfUpx%o)_Vn&gF{}_Pi|9=Gf_iyvw M`VEX58}91@0E%@am;e9( delta 47 zcmeBr#MJeOX+wMA#)eH?oA+lNVFVKU7&q^(U&A;tfNk>bdQPVQ|2OZdU(2|$;i)bF DJoXpf diff --git a/src/lib-tempo/src/component/ComponentStage.cpp b/src/lib-tempo/src/component/ComponentStage.cpp index d245ec5e..00bbcac8 100644 --- a/src/lib-tempo/src/component/ComponentStage.cpp +++ b/src/lib-tempo/src/component/ComponentStage.cpp @@ -215,12 +215,13 @@ void loadButtons(anax::World &world, const char *tile_map) } stbi_image_free(pixel_data); - for (int i = 0; i < 265; i++) { + for (int i = 0; i < 256; i++) { if (buttons[i].empty() || walls[i].empty()) { continue; } fake_createButtonGroup(world, buttons[i], walls[i]); + createButtonGroup(world, buttons[i], walls[i]); } } diff --git a/src/server/main.cpp b/src/server/main.cpp index da7bf1bf..84b39d97 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -85,7 +85,7 @@ int main(int argc, const char **argv) // tempo::createMobCreeper(world, glm::ivec2(14, 14)); // tempo::createMobAntiSnail(world, glm::ivec2(4, 4)); - tempo::loadButtons(world, "levelTest_buttons.bmp"); + tempo::loadButtons(world, "resources/levels/levelTest_buttons.bmp"); world.refresh(); From 283636965694b230352fe6df419112bfc7006872 Mon Sep 17 00:00:00 2001 From: qqii Date: Fri, 16 Mar 2018 00:30:43 +0000 Subject: [PATCH 5/7] Add another group --- bin/resources/levels/levelTest_buttons.bmp | Bin 45322 -> 45322 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/levels/levelTest_buttons.bmp b/bin/resources/levels/levelTest_buttons.bmp index 6f852df1693df4a7055cbe0d65f5bd4822c5ba07..a4246825ec08147799dede4b3fdb98ed3192c0ab 100644 GIT binary patch delta 57 zcmeBr#MJeOX@h(z Date: Fri, 16 Mar 2018 15:56:48 +0000 Subject: [PATCH 6/7] Recreated level buttons using bitmap --- bin/resources/levels/levelTest_buttons.bmp | Bin 45322 -> 45322 bytes .../src/component/ComponentStage.cpp | 22 +----------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/bin/resources/levels/levelTest_buttons.bmp b/bin/resources/levels/levelTest_buttons.bmp index a4246825ec08147799dede4b3fdb98ed3192c0ab..3cbff75754f840b6907674eedcac11f2ab7aee43 100644 GIT binary patch delta 258 zcmeBr#MJeOX~QII#^Q~I69pKJHWp6d7XHP+fQ~j6T5&L@Y%Dy?$e1#*&~LJQDIepB zjfH7oZVZrX4>Ca=nLDv?52Mk wall0 = {{37, 17}, {38, 17}, {39, 17}, {40, 17}, {41, 17}, - {42, 17}, {43, 17}, {44, 17}, {45, 17}}; - createButtonGroup(world, {{40, 12}}, wall0); - - std::vector wall1 = { - {37, 48}, {38, 48}, {39, 48}, {40, 48}, {41, 48}, {42, 48}, {43, 48}, {44, 48}, - }; - createButtonGroup(world, {{40, 43}, {44, 43}, {36, 43}}, wall1); - - std::vector wall2 = {{36, 62}, {36, 63}, {36, 64}, {36, 65}, {36, 66}, - {36, 67}, {36, 68}, {50, 62}, {50, 63}, {50, 64}, - {50, 65}, {50, 66}, {50, 67}, {50, 68}}; - createButtonGroup(world, {{40, 65}}, wall2); - - std::vector wall3 = {{37, 69}, {38, 69}, {39, 69}, {40, 69}, - {41, 69}, {42, 69}, {43, 69}}; - createButtonGroup(world, {{66, 70}, {13, 69}}, wall3); - - std::vector wall4 = {{40, 132}, {41, 132}, {42, 132}}; - createButtonGroup(world, {{41, 110}, {26, 128}, {57, 128}}, wall4); int width, height, components; @@ -203,7 +183,7 @@ void loadButtons(anax::World &world, const char *tile_map) if (b == 0 && r != 0) { // this is a button // r = index - // g = height + // g = level buttons[r].push_back(glm::ivec2(y, x)); } else if (r == 0 && g != 0) { // this is a wall From 3c841411fe8813f34648bb08f420f68b54a3f8a8 Mon Sep 17 00:00:00 2001 From: qqii Date: Fri, 23 Mar 2018 15:20:53 +0000 Subject: [PATCH 7/7] Remove printing for button groups This remove printing "Creating button" as well --- src/lib-tempo/src/component/ComponentStage.cpp | 2 +- src/lib-tempo/src/entity/EntityCreationServer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib-tempo/src/component/ComponentStage.cpp b/src/lib-tempo/src/component/ComponentStage.cpp index 92c141e7..57c182c1 100644 --- a/src/lib-tempo/src/component/ComponentStage.cpp +++ b/src/lib-tempo/src/component/ComponentStage.cpp @@ -200,7 +200,7 @@ void loadButtons(anax::World &world, const char *tile_map) continue; } - fake_createButtonGroup(world, buttons[i], walls[i]); + // fake_createButtonGroup(world, buttons[i], walls[i]); createButtonGroup(world, buttons[i], walls[i]); } } diff --git a/src/lib-tempo/src/entity/EntityCreationServer.cpp b/src/lib-tempo/src/entity/EntityCreationServer.cpp index 32dfae4c..168b50df 100644 --- a/src/lib-tempo/src/entity/EntityCreationServer.cpp +++ b/src/lib-tempo/src/entity/EntityCreationServer.cpp @@ -150,7 +150,7 @@ anax::Entity createButtonGroup(anax::World & world, std::vector positions, std::vector tiles) { - printf("Creating button\n"); + // printf("Creating button\n"); anax::Entity entity_button = world.createEntity(); entity_button.addComponent(positions, tiles); entity_button.addComponent("resources/levels/levelTest.bmp");