This may not be the best way to write this:
This is the 4th day on this project and the code is way clearer than my first prototype, believe me. Comments welcome!Code:double TempRandX = EnemyLowerBounds.x + (static_cast<double>(rand() % ((EnemyLowerBounds.x - EnemyUpperBounds.x) * 10)) * 0.1);
I have this also:
I know the above in my previous draft was this:Code:void Enemy::SetPersonality(const int (&RefPersonality)[20]) { for (int i = 0; i < 20; ++i) { Personality[i] = RefPersonality[i]; } }
The Reference solution seems more C++ ish, but it's definitely more convoluted.Code:void Actor::SetPersonality(int *NewPersonality) { for (size_t i = 0; i < 20; ++i) { Personality[i] = NewPersonality[i]; } }
Are there compelling subtleties to passing an array by reference, versus pointer?
Edit: Grr, I have to do even more casts in the top line to get it to compile. Be right back.
Edit 2:
It compiles now... heck it may even work - but it's a terrible mess.Code:// Random Position double TempRandX = EnemyLowerBounds.x + (static_cast<double>(rand() % (static_cast<int>((EnemyLowerBounds.x - EnemyUpperBounds.x)) * 10)) * 0.1); double TempRandY = EnemyLowerBounds.y + (static_cast<double>(rand() % (static_cast<int>((EnemyLowerBounds.y - EnemyUpperBounds.y)) * 10)) * 0.1); double TempRandZ = EnemyLowerBounds.y + (static_cast<double>(rand() % (static_cast<int>((EnemyLowerBounds.y - EnemyUpperBounds.y)) * 10)) * 0.1); TempRandZ = -28.0; // Currently all actors are locked to -28.0z



LinkBack URL
About LinkBacks



