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.


Topics - DarkYoung

Pages: [1]
1
SFML projects / memoria
« on: September 08, 2013, 01:13:08 pm »
Hi!

I just made a simple game variation inspired by film that i watch (WOW that monekys  :o):


My version is a bit different: You have 5 seconds (or you can just click space) to remember position and order of numbers. After that, numbers hide and you have to point where numbers were in right order. It adds one number after finishing level.

Screen:


Download (only windows, sorry):
https://dl.dropboxusercontent.com/u/75014753/memoria.rar


Enjoy!

P.S.
I suck in game I made by myself...

2
Graphics / [SOLVED]Problem with transformation in own drawable
« on: July 25, 2013, 09:35:46 pm »
Hello,

i'm trying to write my own animation class. My class derive from sf::Drawable and sf::Transformable. Problem is, when i use "setPosition" for example "setPosition(32,48)" animation is rendered at 64,96. There's some code:

void ANIMATION_BASE::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
    if(m_state!="") {
        std::map<const sf::String, ANIMATION_SET>::const_iterator it;
        it=m_animationsSet.find(m_state);
        sf::Vector2f pos;
        pos=getPosition();

        sf::VertexArray vertex_array(sf::Quads, 4);
        vertex_array[0].position=pos;
        vertex_array[1].position=pos+sf::Vector2f(it->second.frameSize.x, 0);
        vertex_array[2].position=pos+sf::Vector2f(it->second.frameSize.x, it->second.frameSize.y);
        vertex_array[3].position=pos+sf::Vector2f(0, it->second.frameSize.y);

        sf::FloatRect frame;
        if(it->second.orientation) {
            frame.left=it->second.textureRect.left+(m_frame*(it->second.frameSize.x));
            frame.top=it->second.textureRect.top;
        } else {
            frame.left=it->second.textureRect.left;
            frame.top=it->second.textureRect.top+(m_frame*(it->second.frameSize.y));
        }
        frame.width=it->second.frameSize.x;
        frame.height=it->second.frameSize.y;


        vertex_array[0].texCoords=sf::Vector2f(frame.left, frame.top);
        vertex_array[1].texCoords=sf::Vector2f(frame.left+frame.width, frame.top);
        vertex_array[2].texCoords=sf::Vector2f(frame.left+frame.width, frame.top+frame.height);
        vertex_array[3].texCoords=sf::Vector2f(frame.left, frame.top+frame.height);

        states.transform*=getTransform();
        states.texture=m_texture;
        target.draw(vertex_array,states);
    }
}

Everything is ok when i delete this line:
states.transform*=getTransform();

But if i do this, i cant rotate, scale etc.

It's my first time with Vertex so maybe i do something wrong  :-[

EDIT:
Finally i found whats wrong. Problem is here:

pos=getPosition();

I was thinking that i need to set vertices in global coords. And now i just realize that i need to set everything locally and then magically everything is rendered in right place when i do "window.draw(animation); ". This Library is awesome!

EDIT2:
Topic can be closed ;)

EDIT3:
Title changed

Pages: [1]