I'm having 2 troubles with the following code. First the AI bat will move faster than the speed I have specified. And second it always hits the ball.
If I created a timer to slow down the executuion of the code would that help or am I totally off the mark here?
I have Seedrnd Millisecs() at the beginning with the graphics command,etc..
Thanks
Function MoveCpuOpponent(player2.player,ball.ball) hit_chance = Rnd(1,4) If ball\y > player2\y And player2\y < 525 Then player2\y = player2\y + 4 If ball\y = player2\y And hit_chance = 1 Then player2\y = ball\y Else player2\y = player2\y + 4 EndIf EndIf If ball\y < player2\y And player2\y > 55 Then player2\y = player2\y - 4 If player2\y = ball\y And hit_chance = 1 Then player2\y = ball\y Else player2\y = player2\y - 4 EndIf EndIf End Function
If I created a timer to slow down the executuion of the code would that help or am I totally off the mark here?
I have Seedrnd Millisecs() at the beginning with the graphics command,etc..
Thanks