Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Bullet Face direction problem  (Read 1577 times)

0 Members and 1 Guest are viewing this topic.

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Bullet Face direction problem
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Bullet Face direction problem
« Reply #1 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Bullet Face direction problem
« Reply #2 on: May 27, 2022, 09:02:32 am »
The bullet travel in the wrong direction.

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Bullet Face direction problem
« Reply #3 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)

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Bullet Face direction problem
« Reply #4 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  :-[

 

anything