Page 1 of 1

FartAnnoyed - Rect not getting assigned values?

Posted: December 16th, 2020, 8:24 pm
by Jankko
Hi friends,

just having kinda seizure already from this, even though it will probably end up being something really stupid.
Basically I'm doing the 1st part of FartAnnoyed (beginner 20.1) and when I was about to test the wall collision of the ball, I was getting insta errors so I debugged to the core and found out my Rect doesn't get assigned any values and I don't know why, even the calculations of Vec2 operations seems kinda off even though the operators overload definitions seem correct to me. Attaching my solution (cleaned it but it still got 8MB so sorry if not cleaned properly) + this screenshot where you can see the operations, there is correct value for center of the ball and the radius but for some reason it doesn't get assigned to the RectF.
fartAnnoyed.zip
(8.57 MiB) Downloaded 206 times
Capture.PNG
(41.45 KiB) Not downloaded yet

Re: FartAnnoyed - Rect not getting assigned values?

Posted: December 16th, 2020, 9:22 pm
by krautersuppe
I did not look into your source code, but some time ago i had the same issue I think. Special thanks to FinalL for his detailed answer:
initializer_list.png
initializer_list.png (52.22 KiB) Viewed 3202 times

Re: FartAnnoyed - Rect not getting assigned values?

Posted: December 17th, 2020, 6:53 am
by albinopapa
This is a very common issue.

The issue is in your two Rect constructors where you are trying to call other Rect constructors.

What you have:

Code: Select all

Rect( const Vec2 topLeft, const Vec2 bottomRight )
{
     Rect( topLeft.x, topLeft.y, bottomRight.x, bottomRight.y );
}
When it should be:

Code: Select all

Rect( const Vec2 topLeft, const Vec2 bottomRight )
     :
Rect( topLeft.x, topLeft.y, bottomRight.x, bottomRight.y )
{
}
Notice the line comes before the opening curly brace.

Same goes for the other constructor passing in a Vec2 and two floats.

Re: FartAnnoyed - Rect not getting assigned values?

Posted: January 12th, 2021, 4:56 pm
by Jankko
Forgot to say thank you, that indeed did the trick. Thank you guys.