How to make a computer play a pong game?

So, my partner and I are trying to make a pong game that is against the computer, but we just could not figure out how to make the computer lose.

We already have the basic material, and it works great, but the computer just does not lose. And we also tried to slow down computer trading using sleep, but whenever the oar moves slowly, the ball also moves slowly.

any advice will help! Thanks

+3
source share
6 answers

And we also tried to slow down computer software using sleep, but whenever the paddle moves slowly, the ball also moves slowly.

You need to make it slower by moving it a shorter distance each time it moves.

+5

"" , , , . , , , , .

, , , , .. , , - .

+4

, , "", . , ?

, , , "" " " , , , . " 1, 1, 1" " 1, 0, 0, 1, 0, 0..." - .

+1
+1

, . - . , . , .

  • . , , . , .

  • . , , .

  • (, , ), .

  • ( 1), .

+1

When you use Sleep, the entire program stops for a few milliseconds. Do you have a game loop? If so, try reducing the transfer amount and do not forget to normalize the acceleration vector.

cpuPadlle.Position += amount * acceleration;

Where:

  • quantity in [0..1]
  • acceleration - 2d vector
0
source

All Articles