int main() { for (int i = 0; i < 20; ++i) { std::cout << mainRandomGenerator.getRandom(0, 1) << " "; } std::cout << std::endl; for (int i = 0; i < 20; ++i) { std::cout << mainRandomGenerator.getRandom(0.2f, 0.2f) << " "; } std::cout << std::endl; for (int i = 0; i < 20; ++i) { std::cout << getInt(0, 10) << " "; } std::cout << std::endl; for (int i = 0; i < 20; ++i) { std::cout << getFloat(0.0f, 1.0f) << " "; } std::cout << std::endl; std::cout << getString(100) << std::endl; }
Enemy::Enemy(int lvl) : EnemyBase() { level = lvl; RandomGenerator rg = RandomGenerator(); name = EnemyName[rg.getRandom(0,5)]; state = EnemyState[rg.getRandom(0, 5)]; health = rg.getRandom(2, 6); alive = true; }
int getInt(int min, int max) { #ifdef HYDRA_FAKE_RANDOM_INT return HYDRA_FAKE_RANDOM_INT; #else return mainRandomGenerator.getRandom(min, max); #endif }
Room::Room() { Boss endBoss = Boss(10); RandomGenerator rg = RandomGenerator(); size = RoomSize[rg.getRandom(0, 2)]; content = RoomContent[rg.getRandom(0, 3)]; description = RoomDescription[rg.getRandom(0, 3)]; appearance = RoomAppearance[rg.getRandom(0, 3)]; lighting = RoomLighting[rg.getRandom(0,3)]; connected[RoomDirection::NORTH] = nullptr; connected[RoomDirection::EAST] = nullptr; connected[RoomDirection::SOUTH] = nullptr; connected[RoomDirection::WEST] = nullptr; visited = false; visiting = false; exit = false; equipment.push_back(Equipment()); }
Warp::Warp(int width, int height, float persistence, int scale, RandomGenerator& rng) { _width = width; _height = height; _persistence = persistence; _scale = scale; for(int i = 0; i < 256; i += 1) { _rnd[i] = rng.getRandom() % 255; } for(int i = 0; i < 256; i += 1) { _grads[i] = Vec2(rng.getUniform(), rng.getUniform()).normalize(); } }
float getFloat(float min, float max) { #ifdef HYDRA_FAKE_RANDOM_FLOAT return HYDRA_FAKE_RANDOM_FLOAT; #else if(min == max) { return min; } if(min > max) { std::swap(min, max); } return mainRandomGenerator.getRandom(min, max); #endif }
Room::Room(int room) { number = room; Boss endBoss = Boss(10); RandomGenerator rg; size = RoomSize[rg.getRandom(0, 2)]; content = RoomContent[rg.getRandom(0, 3)]; description = RoomDescription[rg.getRandom(0, 3)]; appearance = RoomAppearance[rg.getRandom(0, 3)]; lighting = RoomLighting[rg.getRandom(0, 3)]; color = RoomColor[rg.getRandom(0, 3)]; connected[RoomDirection::NORTH] = nullptr; connected[RoomDirection::EAST] = nullptr; connected[RoomDirection::SOUTH] = nullptr; connected[RoomDirection::WEST] = nullptr; visited = false; visiting = false; exit = false; equipment.push_back(Equipment()); if (rg.getRandom(0, 100) < 20) traps.push_back(Trap()); }
int Player::doAttack() { RandomGenerator rg; int retunVal = rg.getRandom( 0, getAttack()); return retunVal; }