Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Thor 2.0 released!  (Read 381496 times)

0 Members and 7 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Thor 2.0
« Reply #285 on: January 11, 2014, 06:06:02 pm »
When building the (thor-)project it would be better or at least more convenient if cmake would create a makefile that in return would build all of the project in the same folder.
You should always build/make the install project, i.e. make install -j4. That way everything will be install to the path specified via CMAKE_INSTALL_PREFIX.

one question: are you the same nexus that is on the c++-forum? if so, thanks for your help there haha
Yes, that's also him. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #286 on: January 11, 2014, 06:23:32 pm »
Thank you expl0it3r, learned something new there :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #287 on: January 11, 2014, 06:27:34 pm »
Thank you expl0it3r, learned something new there :)
It's not as if it weren't mentioned in the tutorial with a red IMPORTANT subtitle :P
(Even if it's written for SFML, for Thor the same applies)
« Last Edit: January 11, 2014, 06:29:40 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Thor 2.0
« Reply #288 on: January 11, 2014, 09:27:46 pm »
I don't know wich compiler you use but this code don't compile :

Action& operator[] (const I& id) {
        return actions[id];
}
 

Code: [Select]
D:\Projets\Projets-c++\TestSFGL\myApplication.h|123|error: invalid types 'ActionMap<std::basic_string<char> >[const char [13]]' for array subscript|

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Re: Thor 2.0
« Reply #289 on: January 12, 2014, 01:17:23 am »
Hi there Nexus,

Is there a way to do this:

thor::Action left_press(sf::Mouse::Left, thor::Action::PressOnce);
thor::Action left_hold(sf::Mouse::Left, thor::Action::Hold);

m_input_map[User_Input::USER_MOUSE_LEFT_PRESS] = left_press | !left_hold;

Basically just saying that USER_MOUSE_LEFT_PRESS cannot be left_hold. The reason I want this is because of this:
 
if (m_input_manager.getInputMap().isActive(User_Input::USER_MOUSE_LEFT_PRESS))
        std::cout << "wassup" << std::endl;

else if (m_input_manager.getInputMap().isActive(User_Input::USER_MOUSE_LEFT_HOLD))
        std::cout << "wassup 2" << std::endl;

Whenever I click once, it'll say "wassup" once and "wassup 2" about 5-6 times. I want there to be a clear difference between USER_MOUSE_LEFT_PRESS and USER_MOUSE_LEFT_HOLD. Is there any way to do this? (PS: setKeyRepeatEnabled is already false)

Thanks!
Current Projects:
Technoport

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #290 on: January 12, 2014, 02:01:38 pm »
I don't know wich compiler you use but this code don't compile :
As this is not Thor's original code, please keep problems about your own library SFGL/ODFAEG out of this thread. If you're trying to adopt Thor's implementation and have problems with it, you should discuss it in your own thread...


Is there a way to do this:
There are && and ! operators for thor::Action, but I think you should approach the problem differently.

Why do you need to differentiate between both actions? The press event is always followed by the key being held down. What do you actually want to achieve?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Thor 2.0
« Reply #291 on: January 12, 2014, 02:33:37 pm »
Quote
As this is not Thor's original code, please keep problems about your own library SFGL/ODFAEG out of this thread. If you're trying to adopt Thor's implementation and have problems with it, you should discuss it in your own thread...

It's not only for my own library..., it doesn't compile in general..., but, anyway I've just changed that and used a normal function instead of the operator[] overloading and it work fine.
The operator[] overlaoding works only with int for me.

But I've a question, why so many classes, is it for optimisation ?

Me I've just a classe action, and a an actionmap (to store the action and the signal), and a thirt class to store every object with a key. (If you have looked at my github repository)
I looked at your code, and I didn't understand very well so I've implemented your system with less code.

« Last Edit: January 12, 2014, 02:40:54 pm by Lolilolight »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #292 on: January 12, 2014, 03:06:23 pm »
But I've a question, why so many classes, is it for optimisation ?
Which classes do you mean? The ones in ActionOperations.hpp represent different nodes in the tree that is built from boolean combinations.

If you have built the same functionality with less code, fine :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Thor 2.0
« Reply #293 on: January 12, 2014, 07:54:55 pm »
Ha ok, then I'm in the right way. :)

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #294 on: January 12, 2014, 09:52:49 pm »
Thank you expl0it3r, learned something new there :)
It's not as if it weren't mentioned in the tutorial with a red IMPORTANT subtitle :P
(Even if it's written for SFML, for Thor the same applies)

Guess im to blame, because i always just build via "make all". :P

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #295 on: January 13, 2014, 02:48:20 am »
okay i need some thor insight:

Im trying to implement the animatorclass for creating animations in my project, but somehow the animate() function crashes my project:

This contains the animator:
class AnimationComponent
:public ComponentBase<AnimationComponent>
{

public:
    sf::Texture tex;
    thor::FrameAnimation walk;

public:
    AnimationComponent(const sf::Texture& t,const sf::Vector2f& p,const thor::Animator<sf::Sprite, std::string>& a)
    :tex(t),animator(a)
    { spr.setTexture(tex); spr.setPosition(p); }

    thor::Animator<sf::Sprite, std::string> animator;
    sf::Sprite spr;
};
 


Here i create a dummy animation:
void addFrames(thor::FrameAnimation& animation, int x, int yFirst, int yLast, float duration = 1.f)
{
        const int step = (yFirst < yLast) ? +1 : -1;
        yLast += step; // so yLast is excluded in the range

        for (int y = yFirst; y != yLast; y += step)
                animation.addFrame(duration, sf::IntRect(36*x, 39*y, 36, 39));
}

void Factory::createDummyAnim()
{
    sf::Image image;
    sf::Texture texture;

        if(!image.loadFromFile("animation.png")){
        std::cout << "No such file" << std::endl;
        }

        image.createMaskFromColor(sf::Color::White);
        if(!texture.loadFromFile("animation.png"))
        std::cout << "Texture gone wrong\n";

        // Define walk animation
        thor::FrameAnimation walk;
        addFrames(walk, 0, 0, 7);                       // Frames 0..7  Right leg moves forward
        addFrames(walk, 0, 6, 0);                       // Frames 6..0  Right leg moves backward

        // Register animations with their corresponding durations
        thor::Animator<sf::Sprite, std::string> animator;
        animator.addAnimation("walk", walk, sf::seconds(1.f));
        animator.playAnimation("walk",true);

        Entity& e = _entitymanager.createEntity();
        _entitymanager.addComponent(new AnimationComponent(texture,sf::Vector2f(100.f,100),animator),e);
}

Here the animator::animate() method crashes my code:
void AnimationSystem::update(const sf::Time& dt)
{
    entitylist& entities = _entitymanager.getEntitiesWithComponent<AnimationComponent>();

    for(auto x: entities){
        constptr<AnimationComponent> ac = _entitymanager.getComponent<AnimationComponent>(x);
        ac->animator.update(dt);
        ac->animator.animate(ac->spr);//This line crashes my program, ac->spr is valid
    }
}

ac is valid and ac->spr 's texture is valid as well.

When i create the whole animator in the last code part my program does not crash. the whol entitysystem works, that is not the problem.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #296 on: January 13, 2014, 08:46:20 am »
Hm, I don't immediately see a mistake. Where does it crash exactly? Are you really sure that getComponent doesn't return a corrupt pointer? Could you maybe show a minimal complete example?

And
for(auto x: entities)
Are you sure you want to copy each entity? Otherwise you have to use auto& x (unless it's a pointer).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #297 on: January 13, 2014, 03:08:23 pm »
Its hard to give a minimal complete example due to the component system, i'll try to create one later (busy right now).
The entitielist is just a vector of pointers, so it should not matter whether i copy those or use a reference.

im pretty sure the componentpointer is not corrupted.
Its not a null pointer, all other components work just like this without a problem and the raw data stored in the components works just fine and does not crash my program when i dereference them. (i can draw the components sprite just fine, only the animate function applied to it crashes)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #298 on: January 13, 2014, 06:49:34 pm »
Now that I looked again at your code, I have a suspicion: Since you copy the animator, it might be that some parts are not updated. Indeed, it looks like the iterator Animator::mPlayingAnimation still points to the old instance.

I'll investigate this, thanks!
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #299 on: January 13, 2014, 10:10:16 pm »
Thanks for the insight.
Guessed it would be the copy that corrupts the inner state of the animator since it runs normally with the components data when i build a "brand new" animator right in the update function, i will look for a work around for the time being.

edit:
small update: you talked about a bug in the copy mechanics so i used pointers instead and it works now without crashing anything! Thank you for your help!
« Last Edit: January 13, 2014, 11:39:42 pm by kingcools »

 

anything