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

Pages: [1]
1
Graphics / Conceptualizing "Ghosting" Sprite Movement
« on: August 29, 2014, 07:58:11 pm »
I have an animated sprite of a walking character.  I would like to achieve something similar to Castlevania:SoTN's "ghosting" effect, seen in this gif when the character is falling:

and in this image (to a lesser extent):


I'm thinking of handling it by:
1) drawing the sprite to a rendertexture.  Successive frames would then
2) offset the sprite by whatever camera movement has taken place,
3) doing a color/alpha pass on the existing "ghosted" render texture,
4) rendering the current sprite in it's normal position, and repeating.

Am I overthinking this and should just use a collection of sf::Sprites along with some setColor's, or is the gpu be the best way to go?

2
Graphics / sf::VertexArray: Help Generating Verticies of This Object
« on: August 09, 2014, 02:06:55 am »
I'm trying to create a light source like in this image:


I see the implementation looking something like this, but I'm stuck as to how to achieve the radius fall-off effect.  Generating a full circle is a trivial case, the case where the angle is not a full circle is interesting, and to be clear, the radius fall-off is the most interesting part of this problem.  I'm looking ideally to use a for loop and create this look for an arbitrarily-sized vertex array, thanks.

struct Light : public sf::Drawable {
        Light( );


        sf::Vector2f    position;       // center of the triangle fan
        sf::Vector2f    direction;      // values clamped [-1, 1]
        float                   radius;
        float                   angle;          // equals pi radians in the image
        sf::Color               color;
        sf::VertexArray verticies;      // TriangleFan

        void                    draw( sf::RenderTarget& target, sf::RenderStates states ) const final override { target.draw( verticies, states ); }
        void                    calculateVerticies( );
};

void Light::calculateVerticies( ) {
        // amazing code, wow so good
}

3
I have two classes which, for the purpose of this exercise, are defined as follows:

class Editor {
public:
struct editorItem_t {
        sf::RectangleShape                                      rect;
        sf::Text                                                        text;
        editorState_t                                           action;
};
std::list<editorItem_t>                                 editorItems;
}

class Game {
public:
        void Game::EditorMode( const sf::Event& currentEvent );
private:
        Editor editor;
}

Please assume that there is a font loaded and that the sf::Text component is currently writing correctly.  EditorMode is defined as follows, and this is where my problem lies.  I'm using C++11 auto notation, but even without that the color-change statements are not working as intended:

void Game::EditorMode( const sf::Event& currentEvent ) {
        //check to see if any editorItem_t rects were clicked
        if ( currentEvent.type == sf::Event::MouseButtonPressed ) {
                if ( sf::Mouse::isButtonPressed( sf::Mouse::Button::Left ) ) {
                        for ( auto itr = editor.editorItems.begin( ); itr != editor.editorItems.end( ); ++itr ) {
                                if ( itr->rect.getGlobalBounds( ).contains( currentEvent.mouseButton.x, currentEvent.mouseButton.y ) ) {
                                        itr->rect.setFillColor( sf::Color::Blue );      //this isn't working at all
                                        itr->text.setColor( sf::Color::White );     //this isn't working at all
                                        std::cout << "But this statement is working fine!" << std::endl;
                                }
                        }
                }
        }
}

The compiler basically seems to be treating the rect.setFillColor and text.SetColor statements as no-ops and I have no idea how to fix this, any help would be much appreciated.

Pages: [1]