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

Pages: [1]
1
General discussions / Wrote a Quake style drop console using SFML
« on: January 19, 2014, 08:50:55 am »
It's a bit convoluted, and could definitely use improvement, but it's something.

Not going to post it the code here yet since it's in major need of cleanup, but I'll post a couple screenshots



2
Audio / [SOLVED]Audio stops after a few hundred consecutive calls
« on: August 06, 2013, 02:49:50 am »
I've been stress testing my engine for a few hours now and have about 1000 entities in one map that call the same sound when they are collided with by the player, after calling this sound about 400 to 500 times the whole sound backend dies with no error, just no sound, period.

Any ideas?

EDIT:
I know that this is a pretty extreme corner case, but I CAN see where this could become an issue down the line.

3
Graphics / A better scrolling background technique
« on: August 05, 2013, 08:49:31 pm »
Today I was playing around with a background I wanted to scroll, and was using the old 2 sf::Sprite technique, but I personally found that distasteful and got to thinking: sf::Texture has setRepeated, and sf::Sprite has setTextureRect, could I use these to my advantage?

And absolutely yes, what I got was a scrolling background with one sf::Sprite which gives me absolute control, I can move it, i can scale it, i can rotate it, i can do anything i want with it. without having to use any external variables either.

The code itself is really simple:
First here is the image


And here is the code
int main()
{
    sf::RenderWindow app(sf::VideoMode(640, 480), "Platform Physics");

    // x = wind, y = gravity
    sf::Vector2f gravity(0.f, .5f);

    sf::RectangleShape playerShape;


    playerShape.setSize(sf::Vector2f(16, 64));
    playerShape.setPosition(32, 0);
    playerShape.setFillColor(sf::Color(140, 36, 58));
   
    sf::RectangleShape floor;
    floor.setPosition(0, 324);
    floor.setSize(sf::Vector2f(640, 16));
 
   sf::Vector2f velocity;

    sf::Time jumpTime;
    sf::Time jumpMaxTime = sf::seconds(0.1f);
    sf::Clock clock;
    sf::Time lastTime;

    sf::Texture texture;
    sf::Sprite background;
    if (texture.loadFromFile("brinstar_bg1.png"))
    {
        texture.setRepeated(true);
        background.setTexture(texture);
    }

    const float MAX_VELOCITY = .2f;

    while(app.isOpen())
    {
        sf::Time currentTime = clock.restart();
        lastTime = currentTime;

        sf::Event event;
        while(app.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                app.close();
        }


        velocity.y += gravity.y*lastTime.asSeconds();

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
            // Immediate stop
            if (velocity.x > 0)
                velocity.x = 0;
            velocity.x -= .2f*lastTime.asSeconds();
        }
        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
            // Immediate stop
            if (velocity.x < 0)
                velocity.x = 0;
            velocity.x += .2f*lastTime.asSeconds();
        }
        else
            velocity.x *= .75f;

        if (velocity.x < -MAX_VELOCITY)
            velocity.x = -MAX_VELOCITY;
        else if (velocity.x > MAX_VELOCITY)
            velocity.x = MAX_VELOCITY;
        if (velocity.y < -MAX_VELOCITY)
            velocity.y = -MAX_VELOCITY;
        else if (velocity.y > MAX_VELOCITY)
            velocity.y = MAX_VELOCITY;


        playerShape.move(velocity);

        if (playerShape.getPosition().x < 0)
            playerShape.setPosition(0, playerShape.getPosition().y);
        if (playerShape.getPosition().x + playerShape.getSize().x > app.getSize().x)
            playerShape.setPosition(app.getSize().x - playerShape.getSize().x, playerShape.getPosition().y);

        background.setOrigin(background.getLocalBounds().width/2, background.getLocalBounds().height/2);
        background.setPosition(background.getLocalBounds().width/2,  background.getLocalBounds().height/2);
        background.setTextureRect(sf::IntRect(-((playerShape.getPosition().x*.125f)), -(playerShape.getPosition().y*.25f), 640, 256));
       
        // Test rotation;
        background.rotate(16.f*lastTime.asSeconds());

        app.clear(sf::Color::Magenta);
        app.draw(background);
        app.draw(floor);
        app.draw(playerShape);
        app.display();
    }

    return 0;
}
 

4
Graphics / SFML 2.0: RenderWindow::GetFrameTime() missing?
« on: February 07, 2012, 09:01:41 pm »
When attempting to get the frame time I discovered that the function is entirely missing. Is this intentional?, if so why?

5
Graphics / Image bpp
« on: May 09, 2010, 05:42:36 am »
I am working on an editor for an snes game I'm sure you are all familiar with: Zelda A Link To The Past, and it uses 4bpp graphics.

Now is it possible to use this mode? Or does it have to converted to 24bpp?

If it can that removes that headache if not, well myself and my programming partner can make do.

Pages: [1]
anything