suzy Posted November 14, 2007 at 09:45 AM Report Share #147282 Posted November 14, 2007 at 09:45 AM tenho um jogador e quero saber qual o jogador que está mais proximo dele, como faço isto atraves da formula da norma do vector em c++? Link to comment Share on other sites More sharing options...
TheDark Posted November 14, 2007 at 10:27 AM Report Share #147287 Posted November 14, 2007 at 10:27 AM "Fixas" um jogador e percorres todos os outros, e às coordenadas de cada um subtrais as coordenadas do jogador fixo (int dx = jogador[i].x - jogadorfixo.x, dy = jogador[i].y - jogadorfixo.y;). Aplicas a fórmula (float dist = sqrt(dx*dx + dy*dy);) e tens a distância entre jogadores. Desaparecido. Link to comment Share on other sites More sharing options...
Rui Carlos Posted November 14, 2007 at 12:35 PM Report Share #147305 Posted November 14, 2007 at 12:35 PM A distância entre x e y é a norma de x-y. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now