ping pong AI

Get help using Construct 2

Post » Wed Oct 31, 2012 11:00 am

hello there

i have made a ping pong game, and settled the 2 player controls but can't get any AI to work. can anybody suggest how to make one
B
20
S
8
G
2
Posts: 122
Reputation: 3,202

Post » Wed Oct 31, 2012 11:17 am

you can searching "pong clone" in search bar of scirra forum . Use it to find what you want to learn.

https://www.scirra.com/forum/search?q=pong+clonefarsmile902012-10-31 11:18:57
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Wed Oct 31, 2012 11:58 am

thanks
@farmsmile
B
20
S
8
G
2
Posts: 122
Reputation: 3,202

Post » Wed Oct 31, 2012 3:36 pm

I would do something like this:

- Every Tick
- If Ball.Y > AIPaddle.Y
-> Set AIPaddle.Y to AIPaddle.Y +2

- Every Tick
- If Ball.Y < AIPaddle.Y
-> Set AIPaddle.Y to AIPaddle.Y -2

The first one would cause the AIPaddle to move up if the ball is above it, the socond part would do the opposite.
For different difficulties, you can change how far it moves for different speeds.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Wed Oct 31, 2012 5:38 pm

thanks game is now uploaded to arcade ( waiting for approval)
B
20
S
8
G
2
Posts: 122
Reputation: 3,202


Return to How do I....?

Who is online

Users browsing this forum: emoticon, KeetonCat, makkancs and 27 guests