Help with PONG, please?

Get help using Construct 2

Post » Tue Jul 11, 2017 12:29 am

Hi,

I am trying to make a PONG game. Basically, on bar on LEFT one on RIGHT and a BALL.

Figured ou most of it, except I cannot make barLEFT (Will be automated - player by computer), I would like to have barLEFT move by itself and follow.Y of BALL.

In other words, player will be playing against computer but barLEFT must be controled in a logical way that it tries to deflect the ball back in an attempt to defeat Player.

Help, please.

Thank you.
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Tue Jul 11, 2017 8:26 am

For Pong I guess you would set the bar's Y to the Y of the ball and to adjust the difficulty you put in delays for its speed in getting to that Y.
B
47
S
17
G
81
Posts: 2,225
Reputation: 48,097

Post » Tue Jul 11, 2017 8:42 am

If you search the Tutorials (I prefer to search via Google) then you will find many examples to learn from, including some with basic AI - the second result is a video tutorial that has basic AI.

Maybe worth a look.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,488
Reputation: 59,762

Post » Tue Jul 11, 2017 11:49 am

In the most basic terms:

Ball.Y > BarLEFT.Y
? Add ( dt * x ) to BarLEFT.Y
: Subtract ( dt * x ) from BarLEFT.Y
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 245
Reputation: 2,314

Post » Tue Aug 01, 2017 1:05 am

Thank you all! Sorry I couldnt reply sooner. Thank you all!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Tue Aug 01, 2017 12:26 pm

Condition: Every Tick
Action: Paddle(Sprite) Then Set Y =
Expression: Ball.Y
B
11
S
3
Posts: 24
Reputation: 723


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests