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 - rojan_neo

Pages: [1] 2
1
Graphics / Re: Assertion failed in running thor animation example
« on: November 21, 2013, 02:34:14 am »
That seems to do the trick. Although I still can't figure out what the problem was.. because I did the exact same steps before   ;D

2
Graphics / Re: Assertion failed in running thor animation example
« on: November 20, 2013, 06:02:19 pm »
I am using visual studio 2010. I am not sure if every thing is linked or not.. Other aspect of the library like resource management and Inputs are working fine but animation is not. I also cannot seem to find the function description for the AddFrame function.. can you tell me where it is located... Maybe I am missing some files...

3
Graphics / Assertion failed in running thor animation example
« on: November 20, 2013, 05:12:53 pm »
I am Trying to run thor::animation example that was provided with the download but i am getting a strange error. It says:
 Assertion Failed: !mFrames.empty() in FrameAnimation.hpp line 115.

It Seems that the frames are not being added to mFrames but I don't know how that could happen.


The part of code where I am getting this error:
void FrameAnimation::operator() (Animated& target, float progress) const
{
        assert(!mFrames.empty());
        assert(progress >= 0.f && progress <= 1.f);

        ensureNormalized();
        AURORA_FOREACH(const detail::Frame& frame, mFrames)
        {
                progress -= frame.duration;
               
                if (progress < 0.f)
                {
                        target.setTextureRect(frame.subrect);
                        break;
                }
        }
}
 

The code is same as in example file

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

// Adds a range of frames, assuming they are aligned as rectangles in the texture.
// animation:      FrameAnimation to modify
// x:              Column index of the texture rectangle
// [yFirst,yLast]: Bounds for row indices (if yLast < yFirst, add frames in reverse order)
// duration:       Relative duration of current frame (1 by default)
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));
}

int main()
{
        sf::RenderWindow window(sf::VideoMode(300, 200), "Thor Animation");
        window.setVerticalSyncEnabled(true);
        window.setKeyRepeatEnabled(false);

        sf::Font font;
        if (!font.loadFromFile("../data/fonts/Primitive.ttf"))
                return 1;

        // Instruction text
        sf::Text instructions(
                "W:     Play walk animation (loop)\n"
                "A:      Play attack animation\n"
                "S:      Stop current animation\n"
                "Esc:  Quit",
                font, 12);

        sf::Text animationText("", font, 12);
        animationText.setPosition(100.f, 150.f);

        // Load image that contains animation steps
        sf::Image image;
        if (!image.loadFromFile("../data/graphics/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 which is animated
        sf::Sprite sprite(texture);
        sprite.setPosition(100.f, 100.f);

        // 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

        // Define attack animation
        thor::FrameAnimation attack;
        addFrames(attack, 1, 0, 3);                     // Frames 0..3  Lift gun
        addFrames(attack, 1, 4, 4, 5.f);        // Frame  4             Aim (5 times normal frame duration)
        for (int i = 0; i < 3; ++i)
                addFrames(attack, 1, 5, 7);             // Frame  5..7  Fire (repeat 3 times)
        addFrames(attack, 1, 4, 4, 5.f);        // Frame  4             Wait
        addFrames(attack, 1, 3, 0);                     // Frame  3..1  Lower gun

        // Define static frame for stand animation
        thor::FrameAnimation stand;
        addFrames(stand, 0, 0, 0);

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

        // Create clock to measure frame time
        sf::Clock frameClock;

        // 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::W:           animator.playAnimation("walk", true);                   break;
                                        case sf::Keyboard::A:           animator.playAnimation("attack");                               break;
                                        case sf::Keyboard::S:           animator.stopAnimation();                                               break;
                                        case sf::Keyboard::Escape:      return 0;
                                }
                        }
                        else if (event.type == sf::Event::Closed)
                        {
                                return 0;
                        }
                }

                // If no other animation is playing, play stand animation
                if (!animator.isPlayingAnimation())
                        animator.playAnimation("stand");

                // Output playing animation (general case; at the moment an animation is always playing)
                if (animator.isPlayingAnimation())
                        animationText.setString("Animation: " + animator.getPlayingAnimation());
                else
                        animationText.setString("");

                // Update animator and apply current animation state to the sprite
                animator.update(frameClock.restart());
                animator.animate(sprite);

                // Draw everything
                window.clear(sf::Color(50, 50, 50));
                window.draw(instructions);
                window.draw(animationText);
                window.draw(sprite);
                window.display();
        }      
}
 

4
Graphics / Displaying multiple lines of text using sf::String
« on: December 21, 2011, 12:08:57 pm »
This works fine when I do this directly within the code.. but since the text that i want tor set is in a text file I read the contents of the file and store the text in std::string variable and do :
Code: [Select]


testString.SetText(stringvariable);

Now when I supply \n character as the content of the file it does not change the line of the sf::String as it used to in previous example!
Any Idea how I'll get through this??

5
Graphics / Displaying multiple lines of text using sf::String
« on: December 21, 2011, 11:52:39 am »
Quote from: "Laurent"
You can insert a '\n' character after each character of the string that is located beyond the container's width.

Do you mean like:
Code: [Select]

sf::String testString;
testString.SetText("one line \n next line");

6
Graphics / Displaying multiple lines of text using sf::String
« on: December 20, 2011, 01:22:33 pm »
How would I display multiple lines of text using one sf::String variable in SFML 1.6?? For example if I use SetText Function for a very long text then it just goes out of bound and the text that falls beyond the size of the window is not displayed!!
How would make something like whenever the text goes out of bound it automatically shifts the text to the next line??

7
Graphics / pop up menu for rpg game
« on: October 02, 2011, 02:38:04 pm »
I am currently working on a turn based rpg game. So far I have:
1. Loaded map from txt files using 32X32 tiles.
2. Loaded objects of the map in a similar way.
3. Collision Detection between objects and player also works fine.

Now the question is:
How would I implement pop up menus for different objects in the game? I have an object class that loads all the objects from the txt file and draws them on screen.

8
Graphics / Simple help needed regarding sf::String.
« on: September 27, 2011, 09:47:23 am »
How would I use an integer variable as a parameter for sf::String.
For eg:
I have a integer variable named m_score that keeps track of player's score. How would I display this information on screen using sf::String (OR IS THERE A BETTER WAY TO DISPLAY THIS ON SCREEN??)

I am using SFML 1.6

9
System / Syntax Error in initializing a Thread
« on: September 19, 2011, 02:58:18 pm »
what if I have more than one parameters of different types

10
System / Syntax Error in initializing a Thread
« on: September 19, 2011, 03:05:24 am »
I am using SFML 1.6 and trying to implement a simple thread as in the following code
Code: [Select]

#include <SFML\Graphics.hpp>
#include <iostream>


using namespace std;
using namespace sf;
void THreadFunc()
{
  ...
}

int main()
{
RenderWindow window(VideoMode(800,600,32), "Box2D");
Event events;
Thread thread(&THreadFunc);
while(window.IsOpened())
{
while(window.GetEvent(events))
{

}

...

window.Clear();
window.Draw(sp);

window.Display();
}


return EXIT_SUCCESS;
}

Now during initialization
Code: [Select]


Thread thread(&THreadFunc);

I get the following error
Code: [Select]


Error 3 error C2664: 'sf::Thread::Thread(sf::Thread::FuncType,void *)' : cannot convert parameter 1 from 'void (__cdecl *)(void)' to 'sf::Thread::FuncType'



Can anyone help??

11
Graphics / Making a player change direction??
« on: September 12, 2011, 02:33:37 am »
I have a simple problem... I am working on the movement of player for a game(top down 2d view)... Basically the player is a sprite filled with other physics such as mass and velocity. Now, I can move the player all over the screen but I want to use angles to make the sprite face in the direction the player is moving. I am having problem on using the concepts of angles for this purpose... Can anyone help??

Let's say a player is in a position (x,y), now when one click on some part of the screen, I want the player to face in that direction and move to it. How would I do that??

12
Graphics / [HELP]SFML Sprite with Box2D
« on: August 28, 2011, 07:14:24 pm »
I already saw that tutorial, That tutorial mainly deals with shapes... I want to use sprites in Box2D.. can anyone help??

13
Graphics / [HELP]SFML Sprite with Box2D
« on: August 28, 2011, 01:56:10 pm »
Can anyone show me how I can tie my sf::sprite with b2body

14
Graphics / click on sprite
« on: August 23, 2011, 05:33:42 pm »
can you be more specific!! do you want some event to be triggered when mouse button is clicked ( at least that is what I understood) then in the main loop you add this code
Code: [Select]

//Here Win is your window
if(Win.GetInput().IsMouseButtonDown(sf::Mouse::Button::Left))
{
Win.Close();
}



This is the case with all the input in SFML

15
Graphics / Removing a Sprite Completely
« on: August 23, 2011, 05:22:58 pm »
I have a condition where the player collects a sprite and then a message pops up that the sprite has been collected. I have a variable keeping track if the sprite has been collected. I draw the sprite on screen only if the sprite is not collected. I check collision with the sprite and if it collided then I set the variable flag as true and the sprite is not drawn on screen.... BUT when I move the player to the previous location of the sprite I still get the pop up message even if the sprite is not there.
So Is there any way I can completely remove the sprite from my game??
I am using the collision code provided in the github page...

Thanks for your attention!!!   :)

Pages: [1] 2
anything