I'm really trying to up my game in game mathematics and now I'm working on enemy movement and a bit of AI. I have an enemy with two modes attack and avoid, based on an integer avoid variable that's either 1 or 0.
On avoid I want it to hover by the player, moving back and forth at a distance until it is set to avoid.
On attack I want to go close at a steady pace say an x and y velocity of 12, then once it reaches a certain distance to gain speed.
I have disx and disy variables that have the distance from each other for each coordinate. I also have a totDis variable with the normal a^2 + b^2 = c^2 formula. I'm pretty sure I'll need another variable that I'll have to change depending on the distance that effects the speed.
It kinda feels like I have all the pieces to the puzzle, I just don't know how to put them together though lol.
I'd like to be able to do this as mathematically as possible and I don't want anyone to give the the answer or do it for me. I was hoping if anyone could give me pointers or tips or just ideas on the directions I can go myself because I really want to have an understanding of this. I hope this is specific enough, if not I'll try to edit my question for you.