Page 2 of 2

Re: Variable at construction not always updating

Posted: January 4th, 2018, 11:03 pm
by MrGodin
Personally I think it's a bug that has been with VS for a while now. Sometimes I can make changes in headers and every .cpp file that includes that header is recompiled as it should. After a while of using VS or for some random reason, this behavior stops and I have to choose Rebuild instead of Build.
I get that problem as well.

Re: Variable at construction not always updating

Posted: January 5th, 2018, 1:09 am
by albinopapa
Yeah, this is the main reason I like to use the CPP files, though I have been working on my SIMD and SIMD math library all in headers and so far only had that issue once.

Re: Variable at construction not always updating

Posted: January 5th, 2018, 2:17 am
by LuisR14
That problem just has to do with the compiler seeing changes from the standpoint of the source files. If any source file that includes the header file is able to see the changes in it, then it would be recompiled properly.

Re: Variable at construction not always updating

Posted: January 5th, 2018, 5:06 am
by albinopapa
Right, that's what should happen, but it doesn't always happen that way is what we're saying.

Re: Variable at construction not always updating

Posted: January 5th, 2018, 11:13 pm
by Neithari
Florian3321 wrote:Hi there!
If I understand your problem, I think it happend due to that you only changed the values in the h file. If you then just build the project, because noting changed in the cpp file, the compiler does not make a new obj and does not link in a new exe, so the changes do not get into the game. If you rebuild, then the "new" h file gets it into the game, and the values are updated. On the one hand you can rebuild the solution or init the variable in the cpp file, not the h file. You can verify what I said if you compile your project, run it in the debugger and step into the constructor of game. If you get to the lines where the construction happens in the h file, Visual Studio tells you that the h file is different form the last build... I had the same problem and found that out, maybe it helps you:) What I do not unterstand is that it works if you build in release mode, maybe because VS rebuilds the project with optimizations?!
Thank you for that explanation. That clarified a lot. Actually it didn't work in release but did in debug. A implementation in the .cpp file worked. :-)

I did some work the last days and I am satisfied with my Invader clone. So thats my first game done :mrgreen: :mrgreen:
I realy learned a lot writing it! And I will take a leap of faith now and start a simple tower defence tomorrow. I think I will use SDL2 for that and hope that I am ready for that. If not I will do it with the ChiliFramework.
Anyway 1 done and so more to do :-) :!: :mrgreen:

Re: Variable at construction not always updating

Posted: January 6th, 2018, 7:21 am
by albinopapa
If you aren't fully commited to SDL2, I would suggest SFML. I found it easier to use and it's in C++ instead of C.

Re: Variable at construction not always updating

Posted: January 6th, 2018, 9:24 pm
by Neithari
albinopapa wrote:If you aren't fully commited to SDL2, I would suggest SFML. I found it easier to use and it's in C++ instead of C.
Most discussions I read have a general sdl2>sfml mentality. I saw a good presentation for sdl2 on YouTube and with all the good comments about it I made the decision for it. But maybe it is worth to have a look at sfml too.

After I showed my space invaders to a friend I noticed that I forgot the ufo and I found a bug. So 1 extra day working on that one and then I'll start with the new.

Re: Variable at construction not always updating

Posted: January 7th, 2018, 2:07 pm
by Neithari
So UFO is added bugs are fixed and my game is like I want it :-) So I am finished with my first game :mrgreen: :mrgreen: :mrgreen:
You can get the compiled Version here:
https://www.dropbox.com/s/auct23b0rofvo ... s.rar?dl=0
And here is my code:
https://github.com/Neithari/Space-Invaders

Re: Variable at construction not always updating

Posted: January 7th, 2018, 6:18 pm
by Florian3321
Congratulations! Looks really cool!