Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMuzzy A

Posted 16 July 2013 - 05:04 PM

You should initialize all of your bools, if not they'll just have garbage that will most likely be non-zero, which is always true. Just set them all to false.

 

Your first check is likely to always be true, given that you've got a velocity applied somewhere. You might want to make it " m_pos.y > 0"

if(m_pos.y != 0)inAir = true;

Same with your max 'y' check, for one, you don't even need the '!falling' in there, because you haven't even touched it yet.

if( m_pos.y == 10 )
 
// Should be
if( m_pos.y >= 10 )

Again this check is useless, you've only assigned to 'rising' once and you set it to false when you did that.

if(rising)

 

Basically everything here that you're doing is wrong or a bad way of doing it.

 

Those booleans that you have should be static, or preferably a data member in your moving object.

 

If you do that then you may find this to be a bit easier than you think.


#2Muzzy A

Posted 16 July 2013 - 05:03 PM

You should initialize all of your bools, if not they'll just have garbage that will most likely be non-zero, which is always true. Just set them all to false.

 

Your first check is likely to always be true, given that you've got a velocity applied somewhere. You might want to make it " m_pos.y > 0"

if(m_pos.y != 0)inAir = true;

Same with your max 'y' check, for one, you don't even need the '!falling' in there, because you haven't even touched it yet.

if( m_pos.y == 10 )
 
// Should be
if( m_pos.y >= 10 )

Again this check is useless, you've only assigned to 'rising' once and you set it to false when you did that.

 

Basically everything here that you're doing is wrong or a bad way of doing it.

 

Those booleans that you have should be static, or preferably a data member in your moving object.

 

If you do that then you may find this to be a bit easier than you think.


#1Muzzy A

Posted 16 July 2013 - 05:02 PM

You should initialize all of your bools, if not they'll just have garbage that will most likely be non-zero, which is always true. Just set them all to false.

 

Your first check is likely to always be true, given that you've got a velocity applied somewhere. You might want to make it " m_pos.y > 0"

 

if(m_pos.y != 0)inAir = true;

 

Same with your max 'y' check, for one, you don't even need the '!falling' in there, because you haven't even touched it yet.

if( m_pos.y == 10 )
 
// Should probablly be
if( m_pos.y >= 10 )

 

Again this check is useless, you've only assigned to 'rising' once and you set it to false when you did that.

 

Basically everything here that you're doing is wrong or a bad way of doing it.

 

Those booleans that you have should be static, or preferably a data member in your moving object.

 

If you do that then you may find this to be a bit easier than you think.


PARTNERS