Subtracting works, addition doesn't?

Started by
21 comments, last by Acoole 15 years ago
13. After you have really fulfilled 11. and 12., I don't want to sound rude, but after you have done that I must assume that your Irony Sensor Device has a slight glitch [smile].

No really, you can't expect people to work through all your code if you seem to not even try out yourself what they proposed to you. See, we all have time constraints, so please, if people already spent some seconds of their time to give you proposals and assistance, then at least try out what they suggest and be at least a bit appreciative (yelling "yay, thanks" or "sooper dooper" is allready enough). They are not here to do your work, and you won't learn if you don't do yourself.

Now, step ahead, work through all points 1.-10., and then come back ;)
Advertisement
I checked the code in your other thread. You have

// Ensure the weapon is firing.
if( fire == false )
return;

//Checks if the player is trying to reload the weapon
if( g_engine->GetInput()->GetKeyPress( DIK_R, false ) )
m_rounds += 1.0f;


Why would the player need to be firing to reload? Maybe you stop firing when you try to reload? Without the source (as you've been asked to provide) this is the only thing I can find.
Trust me, I have tried my best to use the above advice to change bits of code, attempting to compile etc.. with no luck. It is probabbly a very newbie problem, like I am simply putting it in the wrong place. If anybody does seriously want to help, you can view the source here:

Best Regards,
~Andrew

[Edited by - Acoole on April 9, 2009 10:48:25 AM]
Quote:Original post by Acoole
Trust me, I have tried my best to use the above advice to change bits of code, attempting to compile etc.. with no luck. It is probabbly a very newbie problem, like I am simply putting it in the wrong place. If anybody does seriously want to help, you can view the source here: http://www.easy-share.com/1904447183/source.zip

Best Regards,
~Andrew


And where are you telling us what is going wrong?
You are saying that you can't compile your code. We could help if you showed us your code and the corresponding errors, but we can't solve the problem entirely.
Above is the source... and the errors:
Error 5 error C2065: 'script' : undeclared identifier c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\Weapon.cpp 141
Error 6 error C2227: left of '->GetFloatData' must point to class/struct/union/generic type c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\Weapon.cpp 141

if I put it in PlayerManager.cpp, where it should be since that's where all the other controls are I get:

Error 4 error C2065: 'm_rounds' : undeclared identifier c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\PlayerManager.cpp 141
Error 5 error C2065: 'script' : undeclared identifier c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\PlayerManager.cpp 141
Error 6 error C2227: left of '->GetFloatData' must point to class/struct/union/generic type c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\PlayerManager.cpp 141


Best Regards,
~Andrwe
I can't find where script is defined. Which file is it in?
Edit: Nevermind I found it.


Error 4 error C2065: 'm_rounds' : undeclared identifier c:\Users\Andrew Chinnadorai\Desktop\Source\Chapter 13\Game\PlayerManager.cpp 141

m_rounds is a private variable in the weapon class. PlayerManager can't access it.
Hmm? Real newbie but when I change it to public it doesn't make a difference.
you would need to create an instance of a weapon and then use weapon.m_rounds

Also, and I'm kind of new myself, but doesn't "main.h" need to be included in the header files instead of the source files? Then the source file just includes the header file.

So include "main.h" in "weapon.h", and then include "weapon.h" in "weapon.cpp"
Not sure.. but that just confused the hell out of me ..
Quote:Original post by Acoole
Not sure.. but that just confused the hell out of me ..


Sorry.

Including header files is just one of those things I do without thinking about it. (and now that I try to think about it I can't bring myself to be sure I'm right.)

You need to include "main.h" in the Weapon header file. You then need to include "weapon.h" in the Weapon source file. Hopefully this is a bit clearer.

This topic is closed to new replies.

Advertisement