F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MadMaia3D
Posts: 4
Joined: April 5th, 2019, 7:47 am
Location: Brazil

F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by MadMaia3D » April 5th, 2019, 8:10 am

I was ready to start implementing the brick-ball collision. So I was doing some test the game.cpp when something strange started happening. I don't know if I am doing something wrong. I was trying to "call" a Vector 2 constructor inside the Class initializer list, but when I run the application it ignores the statement, so the Vec2 doesn't initialize.

I tried changing the order of the initializers and any statements after "gfx(wnd)," to the vec2 (brickPos) is ignored.

Can Anyone help-me to find what is happening?
You only need to set a break point at the Class initializer list and step over the first lines to see it .
This is the repository link.
https://github.com/MadMaia3D/my_Fart-Annoyed

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by chili » April 5th, 2019, 11:22 am

What file/line do you mean specifically. In you game.cpp ctor I do not see any Vec2 being initialized.
Chili

MadMaia3D
Posts: 4
Joined: April 5th, 2019, 7:47 am
Location: Brazil

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by MadMaia3D » April 5th, 2019, 11:43 am

chili wrote:
April 5th, 2019, 11:22 am
What file/line do you mean specifically. In you game.cpp ctor I do not see any Vec2 being initialized.
Hey Chili!

Looking at the repo at GitHub I saw that the line wasn't there!
So I opened the solution and the bug persisted... I simply deleted the line that was being ignored... build it, inserted the line of code again (not by pasting, but doing it letter by letter) and built it again. Now the problematic line just worked! Maybe some bug with Visual Studio"s Text editor?

Thank you Chili, did you embedded some kind of magic in you reply? :lol:
Sorry for the inconvenience.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by chili » April 5th, 2019, 12:09 pm

lel congrats ;)
Chili

MadMaia3D
Posts: 4
Joined: April 5th, 2019, 7:47 am
Location: Brazil

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by MadMaia3D » April 5th, 2019, 1:10 pm

Hey Chili. I had the same problem again.

I did this:
Game::Game(MainWindow& wnd)
:
wnd(wnd),
gfx(wnd),
brickPos(80,60),
brick(brickPos, 300, 300),
walls(0, 0, 800, 600),
ball(400, 300, -400, -800)
{
}

In this situation the brickPos constructor isn't called... I can't initialize a class and then use it to initialize another class (in the Class initializer list)
The codes compile without error, but when i run this line is skipped (and then the brick gets a "random" negative number that results in an assertion failure when it needs to be drawn)

Why I can't do this?

ps: chili, I'm a big fan

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by chili » April 5th, 2019, 3:01 pm

update your repo
Chili

MadMaia3D
Posts: 4
Joined: April 5th, 2019, 7:47 am
Location: Brazil

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by MadMaia3D » April 5th, 2019, 4:56 pm

Chili, it's was all my fault!!!! You said it in Tutorial 12!
I forgot completely that the initialization follows the order of declaration in the header file!!!
Oh my crap brain! Now I think i will never forget! Thanks for listening!

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: F-Annoyed tutorial - Bug? constructor ignored in Class initializer list

Post by chili » April 6th, 2019, 4:36 am

Haha, that is exactly what I was going to check first (but you only posted code from your Game.cpp) ;)
Chili

Post Reply