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

Pages: [1]
1
General / Re: Mover un objeto hacia el jugador
« on: May 24, 2017, 08:00:30 am »
XD I need to move an object to the player, just like chasing him. My problem is when the player moves the enemy doesn't go to the player, instead it just revolves around till the player stop then it goes to the player position and I need that the enemy goes to the player position in anytime even if the player is moving. I used google transalte, Im bad at English

2
General / Mover un objeto hacia el jugador
« on: May 24, 2017, 07:18:48 am »
Hola, soy nuevo en este foro  :)

Estoy entrando en el mundo de la programación de video juegos en sfml, soy bastante nuevo :p
Mi duda es, como logro hacer que un objeto persiga al jugador en todo momento? es decir si este se mueve hacia cualquier lado de la pantalla, el objeto enemigo debe ser capaz de dirigirse hacia la posición del usuario aunque se este moviendo, No logro conseguirlo. Este es el codigo que use para hacer que el enemigo se mueva hacia el jugador pero mientras el jugador se mueve el enemigo da vueltas a lo loco en lugar se perseguir al usuario como quiero que lo haga
void Enemigo::Mover(Jugador &jugador){
    static const float PI = 3.14159265;
    sf::Vector2f Direccion;
    sf::Vector2f PlayPos = jugador.getCarro().getPosition();
    sf::Vector2f EnePos = enemigo.getPosition();

    float dx = PlayPos.x - EnePos.x;
    float dy = PlayPos.y - EnePos.y;

    rotacion = ((atan2(dy, dx)) * 180 / PI)+180;

    Direccion.x = cos(rotacion);
    Direccion.y = sin(rotacion);

    enemigo.move(Direccion);
}

Cualquier clase de ayuda me vendría bastante bien  :(

In "English"
I need to move an object to the player, just like chasing him. My problem is when the player moves the enemy doesn't go to the player, instead it just revolves around till the player stop then it goes to the player position and I need that the enemy goes to the player position in anytime even if the player is moving. Sorry for the bad english

Pages: [1]
anything