FartAnnoyed - Rect not getting assigned values?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Jankko
Posts: 5
Joined: September 2nd, 2020, 9:58 am

FartAnnoyed - Rect not getting assigned values?

Post by Jankko » December 16th, 2020, 8:24 pm

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

User avatar
krautersuppe
Posts: 91
Joined: September 14th, 2015, 10:58 pm
Location: Istanbul

Re: FartAnnoyed - Rect not getting assigned values?

Post by krautersuppe » December 16th, 2020, 9:22 pm

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 3200 times
DSU
Discord: dsu1, GitHub: https://github.com/DSpUz

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: FartAnnoyed - Rect not getting assigned values?

Post by albinopapa » December 17th, 2020, 6:53 am

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Jankko
Posts: 5
Joined: September 2nd, 2020, 9:58 am

Re: FartAnnoyed - Rect not getting assigned values?

Post by Jankko » January 12th, 2021, 4:56 pm

Forgot to say thank you, that indeed did the trick. Thank you guys.

Post Reply