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

Pages: [1]
1
Window / [Solved] Mouse input is slower than other types of movement
« on: August 30, 2013, 04:21:57 am »
Hi,

I'm trying to implement mouse movement into my game, but the problem I've been running into is that mouse movement is much slower than movement with other input methods (keyboard and joystick). What I'm doing is checking to see if the mouse moved from the center of the window and then moving the sprite and re-positioning the mouse in the center of the window. I have added the relevant code below.

Thanks for your time and any help you provide in advance! Please let me know if you would like more information.

const sf::Vector2i WINDOW_CENTER(window.getSize().x / 2, window.getSize().y / 2);
sf::Mouse::setPosition(WINDOW_CENTER, window);
window.setMouseCursorVisible(false);

if (the joystick moved left || the left key was pressed ||
    sf::Mouse::getPosition(window).x < WINDOW_CENTER.x)
{
    move("left")
    sf::Mouse::setPosition(WINDOW_CENTER, window);
}
if (the joystick moved right || the right key was pressed ||
    sf::Mouse::getPosition(window).x > WINDOW_CENTER.x)
{
    move("right")
    sf::Mouse::setPosition(WINDOW_CENTER, window);
}

I'm using SFML 2.1 with Visual Studio 2012.

2
Graphics / Re: Elements in list are all displaying the same texture
« on: August 24, 2013, 08:38:56 pm »
Thanks a lot for your help guys, it works now! Sorry that I made a redundant thread, I didn't look at the one you guys mentioned. Thanks again for the help!

3
Graphics / [Solved] Elements in list are all displaying the same texture
« on: August 24, 2013, 06:48:24 pm »
Hi,

I'm trying to draw all the members in a list<list<Brick> > where a Brick is one of my classes. The problem is that if I use a list, all of the bricks have the color of the first brick in the first list of bricks. If I use a vector, all of them have the color of the last brick. This happens even if I just use a list<Brick> and push_back all of the bricks. I've pasted the relevant code below.

Thanks for your time and any help you can provide! Please let me know if there is anything else I should add.

// the code where I initialize the lists of bricks
list<Brick> blueBricks (window.getSize().x / 96 - 1, Brick("blueBrick.png"));
list<Brick> goldBricks (window.getSize().x / 96 - 1, Brick("goldBrick.png"));
list<Brick> greenBricks (window.getSize().x / 96 - 1, Brick("greenBrick.png"));

list<list<Brick> > bricks;
bricks.push_back(blueBricks);
bricks.push_back(goldBricks);
bricks.push_back(greenBricks);

// the brick class has private data members brickTexture and brickSprite

// this is the constructor
Brick::Brick(const string& file)
{
    brickTexture.loadFromFile(file);
    brickSprite.setTexture(brickTexture);
    brickSprite.setOrigin(brickSprite.getLocalBounds().width / 2,
        brickSprite.getLocalBounds().height / 2);
    inPlay = true;
}

// this is how I draw the bricks on the window
for (list<list<Brick> >::iterator i = bricks.begin(); i != bricks.end(); ++i)
    for (list<Brick>::iterator j = i->begin(); j != i->end(); ++j)
        j->draw(window);

void Brick::draw(sf::RenderWindow& window)
{
    if (inPlay)
    {
        brickSprite.setPosition(position);
        window.draw(brickSprite);
    }
}
 

I'm using SFML 2.1 with VS 2012 on Windows 7.

Pages: [1]