Hi im trying to make an basic pong app and i am trying to make 3 different ai's
Right now im struggling with making an AI where the paddle of the computer returns to it's base point = the middle of the x axis.
i have an AI where the computer follows the ball when its on his half of the gaming set and an AI where it follows the ball all the time.
and i just cant figure out how to get it to return to its base point everytime the ball passes to my side of the gaming set.
my code looks like this at the time.
Code:
if(mic.center.y <= self.view.center.y) {
if(mic.center.x < plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x - ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
if(mic.center.x > plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x + ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
}
this is the ai which follows the ball on his side.
i figured out that i have to make another if with condition set on
Code:
if(mic.center.y >= self.view.center.y) {
please help.