Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualL. Spiro

Posted 28 November 2013 - 05:28 PM

If you want a more stable loop in which you will need to delete things, use this:
for (int n = bullets.size(); --n >= 0;)
Then you can avoid hacky n-- code in the loop body, plus it’s faster too.

Also, I’ve recently just explained why std::shared_ptr is bad for your health.  You should drop it and find an alternative or write your own game-friendly shared pointer.
 
Finally, a reflection vector.
Given an Incident vector I (the direction of the bullet) and the Normal vector N, a Reflect function can be made as follows:
 
VECTOR Reflect( const VECTOR & I, const VECTOR N ) {
    return I - 2.0f * dot( N, I ) * N;
}
This is exactly the same as calling XMVector2Reflect(), so if XMVector2Reflect( vecBulDir, vecNormal ) works, Reflect( vecBulDir, vecNormal ) works.


L. Spiro

#2L. Spiro

Posted 28 November 2013 - 05:28 PM

If you want a more stable loop in which you will need to delete things, use this:
for (int n = bullets.size(); --n >= 0;)
Then you can avoid hacky n-- code in the loop body, plus it’s faster too.

Also, I’ve recently just explained why std::shared_ptr is bad for your health.  You should drop it and find an alternative or write your own game-friendly shared pointer.
 
Finally, a reflection vector.
Given an Incident vector I (the direction of the bullet) and the Normal vector N, a Reflect function can be made as follows:
 
VECTOR Reflect( const VECTOR & I, const VECTOR N ) {
    return I - 2.0 * dot( N, I ) * N;
}
This is exactly the same as calling XMVector2Reflect(), so if XMVector2Reflect( vecBulDir, vecNormal ) works, Reflect( vecBulDir, vecNormal ) works.


L. Spiro

#1L. Spiro

Posted 28 November 2013 - 05:26 PM

If you want a more stable loop in which you will need to delete things, use this:
for (int n = bullets.size(); --n >= 0;)
Then you can avoid hacky n-- code in the loop body, plus it’s faster too.

Also, I’ve recently just explained why std::shared_ptr is bad for your health.  You should drop it and find an alternative or write your own game-friendly shared pointer.
 
Finally, a reflection vector.
Given an Incident vector I (the opposite direction of the bullet) and the Normal vector N, a Reflect function can be made as follows:
 
VECTOR Reflect( const VECTOR & I, const VECTOR N ) {
    return I - 2.0 * dot( N, I ) * N;
}
This is exactly the same as calling XMVector2Reflect(), so if XMVector2Reflect( vecBulDir, vecNormal ) works, Reflect( vecBulDir, vecNormal ) works.


L. Spiro

PARTNERS