SFML community forums

Help => Graphics => Topic started by: Jan666 on May 27, 2022, 08:04:33 am

Title: Bullet Face direction problem
Post by: Jan666 on May 27, 2022, 08:04:33 am
Hello, i need a solution for a 2d shot game. The player still shot to the right direction, i have no idea how i change the bullet direction when he walk to the left side?


//Touch Shot Button
if(btn.btnRect3.contains(worldPos)){
                                                                       
                           isFiring = true;      
}


//bullet shot details

if(isFiring == true){
       
        bullet newBullet (Vector2f( 20, 20));
        newBullet.bulletSetPos(Vector2f(player.playerSprite.getPosition().x  + 60, player.playerSprite.getPosition().y + 100));
        bulletVec.push_back(newBullet);
        isFiring = false;
   }



 

Any Ideas
Title: Re: Bullet Face direction problem
Post by: eXpl0it3r on May 27, 2022, 09:00:31 am
Do you mean to bullet travels in the wrong direction or the player faces the wrong direction?
Title: Re: Bullet Face direction problem
Post by: Jan666 on May 27, 2022, 09:02:32 am
The bullet travel in the wrong direction.
Title: Re: Bullet Face direction problem
Post by: Jan666 on May 27, 2022, 09:16:07 am
I search something that turn the following values into negative values when the player turns left

The player.playerSprite.getPosition().y + 100)) < -- the 100 have urn into - 100

newBullet.bulletSetPos(Vector2f(player.playerSprite.getPosition().x  + 60, player.playerSprite.getPosition().y + 100));  


 

An the move value 3 have to turn into -3
bulletRec.move(0, 3);

 

For the players face direction i used setScale(3, -3 ) and setScale (3, 3)
Title: Re: Bullet Face direction problem
Post by: Jan666 on May 28, 2022, 12:45:31 pm
Is there any tutorial for a 2d shot game like probotector, i just find spaceship shot directon or topdown examples with angles, i dont need that  :-[