Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc/fix sprites #161

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bin/resources/materials/textures/player_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_0_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_0_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_0_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_1_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_2_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_2_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_2_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_3_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/player_3_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_0_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_0_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_0_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_1_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/resources/materials/textures/rogue_2_1.png
Binary file added bin/resources/materials/textures/rogue_2_2.png
Binary file added bin/resources/materials/textures/rogue_2_3.png
Binary file added bin/resources/materials/textures/rogue_3_0.png
Binary file added bin/resources/materials/textures/rogue_3_1.png
Binary file added bin/resources/materials/textures/rogue_3_2.png
Binary file added bin/resources/materials/textures/rogue_3_3.png
2 changes: 1 addition & 1 deletion src/client/include/client/system/SystemRenderSceneNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
42 changes: 30 additions & 12 deletions src/client/src/system/SystemRenderSceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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<tempo::ComponentModel>();

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;
}

Expand Down
17 changes: 12 additions & 5 deletions src/server/src/system/SystemAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@ bool ai_attack(anax::Entity entity, server::SystemAttack s_attack)
{
if (entity.hasComponent<tempo::ComponentAttack>() && entity.hasComponent<tempo::ComponentWeapon>())
{
tempo::ComponentAttack &a = entity.getComponent<tempo::ComponentAttack>();
tempo::ComponentWeapon &w = entity.getComponent<tempo::ComponentWeapon>();
tempo::ComponentStageRotation &r = entity.getComponent<tempo::ComponentStageRotation>();
auto &st = entity.getComponent<tempo::ComponentStageTranslation>();
auto &a = entity.getComponent<tempo::ComponentAttack>();
auto &w = entity.getComponent<tempo::ComponentWeapon>();
auto &sr = entity.getComponent<tempo::ComponentStageRotation>();

//if we're already attacking then just keep going
if (a.beats_until_attack > -1) return true;

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;
}

Expand Down