# antoniorv6

Member

5

1. ## Algorithm Turret aim

Hi there! I'm currently developing a Turret Defense videogame with C++ and SFML and I'm having some trouble thinking about a feature. In this kind of games, it's commonly seen that turrets keep aiming and attacking to enemies that are into a certain range. I'm struggling to figure out how to program it. Firstly, I came across to use some basic Trigonometry figuring out (thanks to the coordinates of the enemy sprite and our turret), the angle that is needed to be aiming to the bad guy (using the sine arc). Then, I'l substract this result to the initial angle that the turret's sprite has and I think I would obtain a displacement, which I will apply to the rotate() function that SFML provides to their sprites. Anyway, I don't really know if I am right with this hypothesis or if it exists any better option to make this calculus. I tried to look up at some other videogames and I didn't find anything clear. So, I would appreciate a lot if anyone knows any better option or how to refine this first hypothesis. Thank you in advanced!
2. ## Starting in Videogame Music

Hi there! Well, as the subject describes itself. I would like to start in videogame music and composition. I do know some Music Theory and have some notions on how to play the piano, and also in my Degree we have some subjects refered to Sound and Music, but I would like to go a little bit deeper. Anyway, I'd like to know if it there is any site, course, or bibliography refered to all of this, even if it starts from the basic of the basics. Also would be interesting if it is there any good reference to study all the software related to the theme. It would be great if anyone could give me some advice, because now I am a little bit lost. Thank you!
3. ## Turret aim

Well, the project indeed is sort of tower-defense like game I have to do with my team for a University subject. We have thought about making a game with some mechanics of Dungeon of the Endless (where the defense goes by turrets and heroes), so I think it won't be a problem if the turrets auto-aim at high speed, indeed, I had the same worry of rotating animation being a disadvantage. Just as you said, we have planned to make different kinds of turrets, and other weapons, to make a better strategy experience balanced with the heroes control. So I will do as you recommend, I think for this time (I'm still learning) I will get back and make the basic of the basics just aiming and shooting, not worrying about animations yet. Once it is implemented and, if we have time to do it, we will spend some in figuring out this animations. Welp, thank you very much guys! You solved me a lot of doubts I had on how to implement all of this.
4. ## Turret aim

I see your point. and the logic of FindTarget() and Attack() fits the bill with my first thoughts on how to make it. I was asking more about the mathematics of rotating the turret towards the enemy. But this advice also results very handy!! Speaking of which, you are telling me to use manhattan distance to determine de closest target? Finally, I see that you are calling this functions while the Enemy is executing his movement but, could it be better to manage it in the State of the game and distributing the functions with the Turret class? For example, constructing the vector in the State class and then store the enemy location or sth in the Turret class to keep aiming at him? I'm getting a little bit fuzzy thinking about updating the position of THAT particular enemy to THAT turret. Thank you very much!
5. ## Turret aim

I thought the same for calculating the distance between the turret and the enemy (thinking it as retrieving the module of a vector which is determined by substracting both points). I see also that you are getting the angle of the enemy by using the arc tangent, so, just to clear myself, if you calculate the arc tangent of the offset (which is a vector which goes from my turret to the enemy) i will retrieve the angle that is needed? Didn't thought about it!. So then, when I retrieve that angle I just use setRotation() in the sprite and we're done right? Thank you very much!