marine2oorah4u
how do i make a loop or array to choose between different color[]? (csharp)
The thing that I’m worried about or know I’ll have to figure out too is
Which I’m sure I’ll have to do it in the game state or draw?
Is that I’m sure I’ll have to link said skin chopper in a picker scroll system
11 replies
❔ looking to find smneto help me understand offsets via Rects/collission (also help w c# in general)
but at one point, i want to be able to take what my friend says here in this (his post)
and to take this code
and to break each line/condition down or to understand each outcome/scenario better
56 replies
❔ looking to find smneto help me understand offsets via Rects/collission (also help w c# in general)
"Examine this diagram. 4 balls, numbered 1 to 4 (in blue) and the black paddle.
The first line, as the comment says, is testing if the X of point 1/3 of the ball (the left edge) is <= (less than or equal to) the X of point 2/4 of the paddle (the right edge). Because the ball is moving to the left, we are testing if the movement of the ball for this frame (it's velocity) has caused it to move from the right hand side of the paddle right edge to either directly on its right edge or to the left of it. If this is true, then the ball has potentially collided with the paddle on this frame. So now we have to also test the Y positions to check if it has actually hit the paddle, or if it has just moved past it like ball 4 will do.
So the second line of that if statement is testing if the Y of point 1 of the ball is <= (less than or equal to) the Y of point 4 of the paddle. Balls 1, 2 and 3 all meet this condition. Their point 1 Y is <= the paddles point 4 Y. Because ball 4 fails that test, we know it cannot hit the paddle, so it doesn't even bother with the next test.
So if Y of point 1 of the ball is <= point 4 of the paddle, we know it is still possible the ball could have collided with the paddle, so we now do line 3 of that if statement.
Line 3 is testing if the Y of point 3 of the ball is >= (greater than or equal to) the Y of point 2 of the paddle. If the Y is < then we know the ball is above the paddle and has not collided. You will see that the Y of point 3 for all the balls is greater than the Y of point 2 of the paddle, so they will all hit the paddle except ball 4 which we stopped testing for in line 2 (it failed so the if statement aborts and the velocity is not negated).
And that is why line 2 and 3 of that if statement are exactly the same for the other paddle. The Y tests don't change, because we are only testing the left/right (horizontal) edges. If we were to also test the top and bottom edges, which is necessary for a robust collision, then we would also need to change the Y tests depending which edge we are testing."
56 replies