- Code: Select all
if (x>ball.x) x-=2;//this checks if the paddle is farther left than the ball and turns it back
else if (x<ball.x) x+=2;//this does the oposite
if (x>ball.x) x-=2;//this checks if the paddle is farther left than the ball and turns it back
else if (x<ball.x) x+=2;//this does the oposite
Novice wrote:This would make a simple AI, put this in draw actor of the CPU paddle.
- Code: Select all
if (x>ball.x) x-=2;//this checks if the paddle is farther left than the ball and turns it back
else if (x<ball.x) x+=2;//this does the oposite
makslane wrote:In collision between ball and level_1, use the Physical Response:
Move: Event Only
Mass: Use Calculated
Event multiplier: 1
Event multiplier: 1
Final velocity multiplier for event actor: 1.2
int x_range = 70;
int y_range = 70;
if (x < -x_range && balldirection == 4)
{
x = -x_range;
angle = 45;
balldirection = 1;
}
if (x < -x_range && balldirection == 3)
{
x = -x_range;
angle = 135;
balldirection = 2;
}
if (x > x_range && balldirection == 1)
{
x = x_range;
angle = 315;
balldirection = 4;
}
if (x > x_range && balldirection == 2)
{
x = x_range;
angle = 225;
balldirection = 3;
}
if (y < y_range && balldirection == 1)
{
y = y_range;
angle = 135;
balldirection = 2;
}
if (y < y_range && balldirection == 4)
{
angle = 225;
balldirection = 3;
}
Users browsing this forum: No registered users and 1 guest