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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Flojer0

Pages: [1]
1
Graphics / renderWindow.GetFrameTime?
« on: January 24, 2012, 04:52:39 pm »
trying to get thor and sfml up and running for sprite animations. for my latest in errors I get from code::blocks:

sf::RenderWindow’ has no member named ‘GetFrameTime’|

and sure enough I see nothing under render window title as such. here is the source file.



#include <Thor/Animation.hpp>
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(300, 200), "Thor Animation");
    window.SetFramerateLimit(20);
    window.EnableKeyRepeat(false);

    // Instruction text
    sf::Text instructions(
        "D:  Play drive animation (loop)\n"
        "F:  Play fire animation\n"
        "S:  Stop current animation\n"
        "Esc:  Quit");
    instructions.SetCharacterSize(12);
    instructions.SetColor(sf::Color::White);

    // Load image that contains animation steps
    sf::Image image;
    if (!image.LoadFromFile("Media/animation.png"))
        return 1;
    image.CreateMaskFromColor(sf::Color::White);

    // Create texture based on sf::Image
    sf::Texture texture;
    if (!texture.LoadFromImage(image))
        return 1;

    // Create sprite and object that animates it
    sf::Sprite sprite(texture);
    sprite.SetPosition(100.f, 100.f);
    thor::Animator animator;

    // Specify static subrect which is shown unless an other animation is active
    thor::FrameAnimation::Ptr defaultAnim = thor::FrameAnimation::Create();
    defaultAnim->AddFrame(1.f, sf::IntRect(0, 21, 44, 21));
    animator.SetDefaultAnimation(defaultAnim, 1.f);

    // Create first animation and register it at the animator
    thor::FrameAnimation::Ptr drive = thor::FrameAnimation::Create();
    for (unsigned int i = 0; i < 3; ++i)
        drive->AddFrame(1.f, sf::IntRect(0, 21*i, 44, 21));
    animator.AddAnimation("drive", drive, 0.4f);

    // Create second animation and register it at the animator
    thor::FrameAnimation::Ptr fire = thor::FrameAnimation::Create();
    for (unsigned int i = 0; i < 4; ++i)
        fire->AddFrame(1.f, sf::IntRect(44, 21*i, 49, 21));
    animator.AddAnimation("fire", fire, 0.3f);

    // Main loop
    for (;;)
    {
        // Handle events
        sf::Event event;
        while (window.PollEvent(event))
        {
            if (event.Type == sf::Event::KeyPressed)
            {
                switch (event.Key.Code)
                {
                case sf::Keyboard::D:
                    animator.PlayAnimation("drive", true);
                    break;
                case sf::Keyboard::F:
                    animator.PlayAnimation("fire");
                    break;
                case sf::Keyboard::S:
                    animator.StopAnimation();
                    break;
                case sf::Keyboard::Escape:
                    return 0;
                }
            }
            else if (event.Type == sf::Event::Closed)
            {
                return 0;
            }
        }

        // Update animator and apply current animation state to the sprite
        animator.Update(window.GetFrameTime() / 1000.f);
        animator.Animate(sprite);

        // Draw everything
        window.Clear(sf::Color(50, 50, 50));
        window.Draw(instructions);
        window.Draw(sprite);
        window.Display();
    }
}


thanks

2
General discussions / Building Thor c++ lib Ubuntu
« on: January 16, 2012, 02:01:48 am »
Alright, I got thor and a newer sfml to build (the one linked on the thor download page). now code::blocks isn't agreeing with me. But that's  a concern for another day and I may be able to figure that out.

It ended up that ubuntu had seperated sfml's, and they were the same way after building include and lib folders. So after building sfml myself I had to move some folders around to get Thor to agree. Now it appears I just have acouple of kinks to iron out to make things compile.

Thanks again :)

3
General discussions / Building Thor c++ lib Ubuntu
« on: January 15, 2012, 01:33:10 am »
I've been trying to build the Thor c++ library for ubuntu so that I wouldn't have to make my own animation code.

I follow the outline to build with cmake. tell it that SFMLDIR is under /usr/include/SFML. But I cannot figure out where to tell it to put SFML_DIR.

The header files are under said directory but cmake doesn't like it. And I can't find out where else it could be. I originally installed sfml through the synaptic package manager. I considered building sfml myself just to get to this include folder but that didn't go well.

I am currently using cmake 2.8.5 on lubuntu 11.10 and SFML 1.6.

Thanks for any assistance. :)

Pages: [1]