Variables Problem

hello every one. i am making a brick breaker game and im trying to detect when the ball hits the bricks. something quite strange happens.

1
2
3
4
5
6
7
8
9
for(unsigned int i = 0; i < Bricks.size(); i++)
	{
		Brick* b = Bricks[i];
		cout << b->y << endl;
		if(bally+ballsize > 1.85-b->y)
		{
			cout << b->y << endl;
		}
	}


Bricks is the vector holding all the info about each brick. now the first cout statement says the real translated value of the bricks. the second one says 0 for all of them. can anyone please explain to me what i am doing wrong? thanks!
You're saying that b->y is set to zero between line 4 and 7?
You sure you didn't leave out some relevant code?
no b->y in line 4 is set to the value its meant to be there are 4 values ( 0, 0.25, 0.5, 1) and in line 7 they are all 0. this code is copied and pasted from the source code. im asking how could it have changed.
Last edited on
What does the debugger tell you? Step through it and keep track of the state and how/when it changes.
when i use the debugger it says that all the values are 0. but the output is not. i dont know why tho?
Last edited on
IT seems like that only bricks that are close enough to the ball are with zero y values. Do you have your condition right? Did you mean this?
1
2
3
4
5
6
7
8
9
for(unsigned int i = 0; i < Bricks.size(); i++)
{
	Brick* b = Bricks[i];
	cout << b->y << endl;
	if(bally+ballsize > b->y - 1.85)
	{
		cout << b->y << endl;
	}
}
Topic archived. No new replies allowed.