pong frustations

okay here is my problem i been trying to get my collsion agaist my paddles to work and i simply can't do it.

here is a list of my varibles and all the differant codes i have tried to get it to collide

variables and images used
int ball = LoadTexture ("./images/ball.png");
int leftpaddle_2 = LoadTexture ("./images/paddle_2.png");
int rightpaddle_1 = LoadTexture ("./images/paddle_1.png");


float ballx = 492;
float bally = 384;
float ballxspeed = 4;
float ballyspeed = 2;
float rightpaddle_1x = 1000;
float rightpaddle_1y = 20;
float leftpaddle_2x = 5;
float leftpaddle_2y = 450;
float ballrside = ballx + 40;
float position = 0;

collision codes here:

{
if(ballx > 1000 || bally > 450)

if(ballx < 20 || bally < 5)

if (bally < leftpaddle_2x)

if (bally = leftpaddle_2y - position)

if(ballx = bally + leftpaddle_2y)
return(0);
}


if (ballx + 100> rightpaddle_1y && ballx + 100 < rightpaddle_1x && bally)

would it help if i added variable like length and width of the paddles to the collision code?

1
2
3
4
5
6
if(ballx > 1000 || bally > 450)
	if(ballx < 20 || bally < 5)
		if (bally < leftpaddle_2x)
			if (bally = leftpaddle_2y - position)
				if(ballx = bally + leftpaddle_2y)
					return(0);


If this is the actual code.. I can see why you're not having much luck with it.

= is for assignment, by the way. == is for comparison.
Topic archived. No new replies allowed.