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

Pages: [1]
1
General / Re: Sprite.move()
« on: April 22, 2022, 10:33:45 am »
You're right, that was setting position through variable pos. Thank you very much!

2
General / Re: Sprite.move()
« on: April 21, 2022, 11:18:39 pm »
Yes, I'm sure, I was checking bigger numbers to check is it work and it didn't. And yes I'm keeping the player at the right side of the screen.

3
General / Sprite.move()
« on: April 21, 2022, 12:55:16 pm »
Hi, I'm trying to create first simple game using SFML but while working on player moving I stand upon one problem, function won't work in my class, here is fragment of my code:
void Player::PlayerMoving(int offset_x_min, int offset_x_max, int offset_y, sf::View view, int speed_x, int speed_y, float cameraSpeed) {
    //it's keep player on view while camera is moving
    if (pos.x <= view.getCenter().x - offset_x_min) {
            pos = sf::Vector2f(pos.x += cameraSpeed, pos.y);
    }
   
    //pos = viev.getCenter() - sf::Vector2f(offset_x, offset_y);

    if ((sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) && (pos.x > view.getCenter().x - offset_x_min))
    {
        // left key is pressed: move our character
        //pos = sf::Vector2f(pos.x -= speed_x, pos.y); //my version of move but it's not fluent
        sprite.move(sf::Vector2f(1.f ,0.f));
        //sprite.rotate(2); //just for testing and it's working

    }
...
 
I was looking for solution but couldn't find any.

Pages: [1]