Subtracting works, addition doesn't?

Started by
21 comments, last by Acoole 15 years ago
The code m_rounds -= 1.0f; when being used after a shot has been takes place works. The code: //Checks if the player is trying to reload the weapon if( g_engine->GetInput()->GetKeyPress( DIK_R, false ) ) m_rounds += 1.0f; :::::: Doesn't work... Any help on this? Appreciated. Best Regards, ~Andrew Please don't mark threads 'solved' on this forum. -- jpetrie [Edited by - jpetrie on April 9, 2009 10:14:54 AM]
Advertisement
1. Define "doesn't work". What is the value of m_rounds before and after the addition?
2. What is the type of m_rounds?
3. You really shouldn't be using DirectInput for keyboard input. It just causes pain.
m_rounds reads from a script that defines it originally it then changes(it's a float)when a bullet is shot, it goes down by one, once it reaches 0 you can no longer shoot and then you are supposed to click 'R' which just sets m_rounds to the original script value again.
4. Does control flow ever enter the line "m_rounds += 1.0f;" ?
5. How is "GetKeyPress( DIK_R, false )" defined?
6. Do you have some more context to show?
Hmm, wait.. I don't want to add, I want 'R' to reset m_rounds to *script->GetFloatData( "reload" ); , how would I go about doing this?
7. Write "m_rounds = *script->GetFloatData( "reload" );" instead of "m_rounds += 1.0f;"
4. 8. Does control flow ever enter the line "m_rounds += 1.0f;" "m_rounds = *script->GetFloatData( "reload" );" ?
The entire Weapon.cpp can be seen here: http://pastebin.com/m725c699
7. 9. Write "m_rounds = *script->GetFloatData( "reload" );" instead of "m_rounds += 1.0f;"
4. 8. 10. Does control flow ever enter the line "m_rounds += 1.0f;" "m_rounds = *script->GetFloatData( "reload" );" ?
11. Can you post the sourcecode of your entire game including the makefile so that we can compile your code to get the answer for 4. 8. 10. and whether 7. 9. works or not?
12. Given that your last reply was quite some time ago, you are not really fulfilling 11. right now, not?
PM'd you the source.

This topic is closed to new replies.

Advertisement