diff --git a/bin/resources/materials/textures/player_0_0.png b/bin/resources/materials/textures/player_0_0.png new file mode 100644 index 00000000..23fb2ce3 Binary files /dev/null and b/bin/resources/materials/textures/player_0_0.png differ diff --git a/bin/resources/materials/textures/player_0_1.png b/bin/resources/materials/textures/player_0_1.png new file mode 100644 index 00000000..e1792929 Binary files /dev/null and b/bin/resources/materials/textures/player_0_1.png differ diff --git a/bin/resources/materials/textures/player_0_2.png b/bin/resources/materials/textures/player_0_2.png new file mode 100644 index 00000000..7d12ef72 Binary files /dev/null and b/bin/resources/materials/textures/player_0_2.png differ diff --git a/bin/resources/materials/textures/player_0_3.png b/bin/resources/materials/textures/player_0_3.png new file mode 100644 index 00000000..b0f4d7c4 Binary files /dev/null and b/bin/resources/materials/textures/player_0_3.png differ diff --git a/bin/resources/materials/textures/player_1_0.png b/bin/resources/materials/textures/player_1_0.png new file mode 100644 index 00000000..ad99882e Binary files /dev/null and b/bin/resources/materials/textures/player_1_0.png differ diff --git a/bin/resources/materials/textures/player_1_1.png b/bin/resources/materials/textures/player_1_1.png new file mode 100644 index 00000000..8d432d60 Binary files /dev/null and b/bin/resources/materials/textures/player_1_1.png differ diff --git a/bin/resources/materials/textures/player_1_2.png b/bin/resources/materials/textures/player_1_2.png new file mode 100644 index 00000000..22495003 Binary files /dev/null and b/bin/resources/materials/textures/player_1_2.png differ diff --git a/bin/resources/materials/textures/player_1_3.png b/bin/resources/materials/textures/player_1_3.png new file mode 100644 index 00000000..b9210914 Binary files /dev/null and b/bin/resources/materials/textures/player_1_3.png differ diff --git a/bin/resources/materials/textures/player_2_0.png b/bin/resources/materials/textures/player_2_0.png new file mode 100644 index 00000000..92670221 Binary files /dev/null and b/bin/resources/materials/textures/player_2_0.png differ diff --git a/bin/resources/materials/textures/player_2_1.png b/bin/resources/materials/textures/player_2_1.png new file mode 100644 index 00000000..88cf240e Binary files /dev/null and b/bin/resources/materials/textures/player_2_1.png differ diff --git a/bin/resources/materials/textures/player_2_2.png b/bin/resources/materials/textures/player_2_2.png new file mode 100644 index 00000000..4b804ced Binary files /dev/null and b/bin/resources/materials/textures/player_2_2.png differ diff --git a/bin/resources/materials/textures/player_2_3.png b/bin/resources/materials/textures/player_2_3.png new file mode 100644 index 00000000..3cd2f4b4 Binary files /dev/null and b/bin/resources/materials/textures/player_2_3.png differ diff --git a/bin/resources/materials/textures/player_3_0.png b/bin/resources/materials/textures/player_3_0.png new file mode 100644 index 00000000..d327842f Binary files /dev/null and b/bin/resources/materials/textures/player_3_0.png differ diff --git a/bin/resources/materials/textures/player_3_1.png b/bin/resources/materials/textures/player_3_1.png new file mode 100644 index 00000000..44e611b8 Binary files /dev/null and b/bin/resources/materials/textures/player_3_1.png differ diff --git a/bin/resources/materials/textures/player_3_2.png b/bin/resources/materials/textures/player_3_2.png new file mode 100644 index 00000000..1f74d4b5 Binary files /dev/null and b/bin/resources/materials/textures/player_3_2.png differ diff --git a/bin/resources/materials/textures/player_3_3.png b/bin/resources/materials/textures/player_3_3.png new file mode 100644 index 00000000..c1465af2 Binary files /dev/null and b/bin/resources/materials/textures/player_3_3.png differ diff --git a/bin/resources/materials/textures/rogue_0_0.png b/bin/resources/materials/textures/rogue_0_0.png new file mode 100644 index 00000000..aef5f53e Binary files /dev/null and b/bin/resources/materials/textures/rogue_0_0.png differ diff --git a/bin/resources/materials/textures/rogue_0_1.png b/bin/resources/materials/textures/rogue_0_1.png new file mode 100644 index 00000000..60cb39e3 Binary files /dev/null and b/bin/resources/materials/textures/rogue_0_1.png differ diff --git a/bin/resources/materials/textures/rogue_0_2.png b/bin/resources/materials/textures/rogue_0_2.png new file mode 100644 index 00000000..a8eae8c4 Binary files /dev/null and b/bin/resources/materials/textures/rogue_0_2.png differ diff --git a/bin/resources/materials/textures/rogue_0_3.png b/bin/resources/materials/textures/rogue_0_3.png new file mode 100644 index 00000000..300a1440 Binary files /dev/null and b/bin/resources/materials/textures/rogue_0_3.png differ diff --git a/bin/resources/materials/textures/rogue_1_0.png b/bin/resources/materials/textures/rogue_1_0.png new file mode 100644 index 00000000..ada1b7cf Binary files /dev/null and b/bin/resources/materials/textures/rogue_1_0.png differ diff --git a/bin/resources/materials/textures/rogue_1_1.png b/bin/resources/materials/textures/rogue_1_1.png new file mode 100644 index 00000000..39bb00a7 Binary files /dev/null and b/bin/resources/materials/textures/rogue_1_1.png differ diff --git a/bin/resources/materials/textures/rogue_1_2.png b/bin/resources/materials/textures/rogue_1_2.png new file mode 100644 index 00000000..b8362343 Binary files /dev/null and b/bin/resources/materials/textures/rogue_1_2.png differ diff --git a/bin/resources/materials/textures/rogue_1_3.png b/bin/resources/materials/textures/rogue_1_3.png new file mode 100644 index 00000000..d027fb5f Binary files /dev/null and b/bin/resources/materials/textures/rogue_1_3.png differ diff --git a/bin/resources/materials/textures/rogue_2_0.png b/bin/resources/materials/textures/rogue_2_0.png new file mode 100644 index 00000000..5053e782 Binary files /dev/null and b/bin/resources/materials/textures/rogue_2_0.png differ diff --git a/bin/resources/materials/textures/rogue_2_1.png b/bin/resources/materials/textures/rogue_2_1.png new file mode 100644 index 00000000..7c386dc7 Binary files /dev/null and b/bin/resources/materials/textures/rogue_2_1.png differ diff --git a/bin/resources/materials/textures/rogue_2_2.png b/bin/resources/materials/textures/rogue_2_2.png new file mode 100644 index 00000000..5b3bb9c9 Binary files /dev/null and b/bin/resources/materials/textures/rogue_2_2.png differ diff --git a/bin/resources/materials/textures/rogue_2_3.png b/bin/resources/materials/textures/rogue_2_3.png new file mode 100644 index 00000000..e52e388f Binary files /dev/null and b/bin/resources/materials/textures/rogue_2_3.png differ diff --git a/bin/resources/materials/textures/rogue_3_0.png b/bin/resources/materials/textures/rogue_3_0.png new file mode 100644 index 00000000..84cc2e58 Binary files /dev/null and b/bin/resources/materials/textures/rogue_3_0.png differ diff --git a/bin/resources/materials/textures/rogue_3_1.png b/bin/resources/materials/textures/rogue_3_1.png new file mode 100644 index 00000000..493d8f9f Binary files /dev/null and b/bin/resources/materials/textures/rogue_3_1.png differ diff --git a/bin/resources/materials/textures/rogue_3_2.png b/bin/resources/materials/textures/rogue_3_2.png new file mode 100644 index 00000000..a26ffa13 Binary files /dev/null and b/bin/resources/materials/textures/rogue_3_2.png differ diff --git a/bin/resources/materials/textures/rogue_3_3.png b/bin/resources/materials/textures/rogue_3_3.png new file mode 100644 index 00000000..8b0dbef4 Binary files /dev/null and b/bin/resources/materials/textures/rogue_3_3.png differ diff --git a/src/client/include/client/system/SystemRenderSceneNode.hpp b/src/client/include/client/system/SystemRenderSceneNode.hpp index d747ded8..b4904338 100644 --- a/src/client/include/client/system/SystemRenderSceneNode.hpp +++ b/src/client/include/client/system/SystemRenderSceneNode.hpp @@ -25,7 +25,7 @@ class SystemRenderSceneNode // Creates a static red square for all components with positions and render nodes void setup(irr::scene::ISceneManager *smgr,irr::video::IVideoDriver * driver); // Updates the positions of all render scene node according to the stage position - void update(); + void update(irr::video::IVideoDriver *driver); }; } // namespace client diff --git a/src/client/main.cpp b/src/client/main.cpp index 3bb68be3..ec1e4f9a 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -349,7 +349,7 @@ int main(int argc, const char** argv) system_translation_animation.updateAnimations(); // Graphics updates - system_render_scene_node.update(); + system_render_scene_node.update(driver); system_render_health_bars.update(); system_render_healing.update(); diff --git a/src/client/src/system/SystemRenderSceneNode.cpp b/src/client/src/system/SystemRenderSceneNode.cpp index 26a79438..78a1c168 100644 --- a/src/client/src/system/SystemRenderSceneNode.cpp +++ b/src/client/src/system/SystemRenderSceneNode.cpp @@ -52,26 +52,21 @@ void SystemRenderSceneNode::setup(irr::scene::ISceneManager *smgr, irr::video::I sn.node->setPosition(irr::core::vector3df(0.0f, 0.0f, 0.0f)); sn.billboard = new irr::scene::YAlignedBillboardSceneNode(sn.node, smgr, -1, pos, size, color, color); - const std::string& path = m.path; - std::cout << path << std::endl; - irr::video::ITexture *spritesheet = driver->getTexture(path.c_str()); - driver->setTextureCreationFlag(irr::video::ETCF_ALWAYS_32_BIT,true); // sn.billboard->setColor(color); sn.billboard->setMaterialFlag(irr::video::EMF_LIGHTING, false); sn.billboard->setMaterialType( irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL ); - sn.billboard->setMaterialTexture( 0, spritesheet); - + sn.spriteDim = m.spriteDim; - sn.billboard->getMaterial(0).getTextureMatrix(0).setTextureScale(1.f / sn.spriteDim.y, 1.f / sn.spriteDim.x); + sn.updateNeeded = true; } } - update(); + update(driver); } -void SystemRenderSceneNode::update() +void SystemRenderSceneNode::update(irr::video::IVideoDriver *driver) { auto entities = getEntities(); @@ -94,11 +89,34 @@ void SystemRenderSceneNode::update() } sn.spritePos.y = (float) ((dirIndex + 3) % 4) / sn.spriteDim.y; if (sr.previousFacing == sr.facing) { - sn.spritePos.x = sn.spritePos.x + 1.f / sn.spriteDim.x; + ++sn.spritePos.x; } else { - sn.spritePos.x = 1.f / sn.spriteDim.x; + sn.spritePos.x = 0; + } + + tempo::ComponentModel &m = entity.getComponent(); + + char path_buffer [512]; + char extension_buffer[ 32]; + + strcpy(path_buffer, m.path.c_str()); + + char* last_dot = nullptr; + char* cur = path_buffer; + while(*cur){ + if(*cur == '.'){ last_dot = cur; } + ++cur; } - sn.billboard->getMaterial(0).getTextureMatrix(0).setTextureTranslate(sn.spritePos.x, sn.spritePos.y); + + strcpy(extension_buffer, last_dot); + last_dot[0] = '_'; + last_dot[1] = '0' + (dirIndex + 3) % 4; + last_dot[2] = '_'; + last_dot[3] = '0' + ((int)sn.spritePos.x) % 4; + strcpy(&last_dot[4], extension_buffer); + + irr::video::ITexture* sprite = driver->getTexture(path_buffer); + sn.billboard->setMaterialTexture(0, sprite); sn.updateNeeded = false; } diff --git a/src/server/src/system/SystemAI.cpp b/src/server/src/system/SystemAI.cpp index c199db5c..18678a3a 100644 --- a/src/server/src/system/SystemAI.cpp +++ b/src/server/src/system/SystemAI.cpp @@ -11,9 +11,10 @@ bool ai_attack(anax::Entity entity, server::SystemAttack s_attack) { if (entity.hasComponent() && entity.hasComponent()) { - tempo::ComponentAttack &a = entity.getComponent(); - tempo::ComponentWeapon &w = entity.getComponent(); - tempo::ComponentStageRotation &r = entity.getComponent(); + auto &st = entity.getComponent(); + auto &a = entity.getComponent(); + auto &w = entity.getComponent(); + auto &sr = entity.getComponent(); //if we're already attacking then just keep going if (a.beats_until_attack > -1) return true; @@ -21,10 +22,16 @@ bool ai_attack(anax::Entity entity, server::SystemAttack s_attack) glm::ivec2 direction; if (s_attack.bestAttack(entity, direction)) { - if (r.facing != direction) + if (sr.facing != direction) { //face the player, no cheating here - r.facing = direction; + sr.facing = direction; + sf::Packet update_broadcast; + update_broadcast << entity.getId() << sr.facing.x << sr.facing.y + << st.delta.x << st.delta.y << true; + + tempo::broadcastMessage(tempo::QueueID::MOVEMENT_INTENT_UPDATES, + update_broadcast); return true; }