void World::initShips() { // space ship PhysicsObjectId id(PhysicsObjectId::TYPE_SHIP, PhysicsObjectId::FLEET_PLAYER, 0); m_playerShip.init("Grapple", Const::SHIP_SIZE); m_playerShip.setId(id); m_playerShip.setPosition(Const::SHIP_POSITION); m_playerShip.setAmmo(8); m_playerShip.setHealth(Const::PLAYER_HEALTH); m_playerShip.setSpeed(Const::MOVE_PER_FRAME); // space ships id.m_type = PhysicsObjectId::TYPE_SHIP; id.m_fleet = PhysicsObjectId::FLEET_ENEMY; ObjModel model; model.load(Const::MODEL_DIR + Const::ENEMY_SHIP_MODEL_NAME + Const::EXTENSION); DisplayList displayList = model.getDisplayList(); for (int i = 1; i <= Const::MOON_COUNT; i++) { for (int j = 0; j < Const::SHIPS_PER_MOON; j++){ int index = (i - 1) * Const::SHIPS_PER_MOON + j; id.m_index = index; Vector3 position = m_planetoids[i].getPosition() + Vector3::getRandomUnitVector()*(m_planetoids[i].getScaledSize() + 500.0); m_ships[index].initPhysics(id, position, 1.0, 0, displayList, Const::ENEMY_SHIP_SIZE); m_ships[index].setHealth(1); m_ships[index].setUnitAi(new StemCell::UnitAiMoonGuard(m_ships[index], *this, m_planetoids[i].getId())); m_ships[index].setManeuverability(Const::SHIP_MAX_SPEED,Const::SHIP_ACCELERATION,Const::ROTATION_RATE); } } }
void World :: init () { if(!isInitialized()) { // Skybox Init ObjModel sb; sb.load("Models/Skybox.obj"); skybox = sb.getDisplayList(); // Planet Init ObjModel p; p.load(planetInfo.filename); DisplayList p_dl = p.getDisplayList(); PhysicsObjectId p_id = PhysicsObjectId(PhysicsObjectId::TYPE_PLANETOID, PhysicsObjectId::FLEET_NATURE, 0); planet.initPlanetoid(p_id, planetInfo.position, planetInfo.radius, p_dl, 1.f); // Moon Init for (int i = 0; i < MOON_COUNT; i++) { ObjModel m; m.load(moonInfo[i].filename); DisplayList m_dl = m.getDisplayList(); PhysicsObjectId m_id = PhysicsObjectId(PhysicsObjectId::TYPE_PLANETOID, PhysicsObjectId::FLEET_NATURE, i + 1); moons[i].initPlanetoid(m_id, moonInfo[i].position, moonInfo[i].radius, m_dl, 1.f); } // Ship Init ObjModel s; s.load("Models/Grapple.obj"); DisplayList s_dl = s.getDisplayList(); for (int i = 0; i < SHIP_COUNT; i++) { PhysicsObjectId s_id = PhysicsObjectId(PhysicsObjectId::TYPE_SHIP, PhysicsObjectId::FLEET_ENEMY, i); int moonIndex = rand() % MOON_COUNT; Vector3 pos = moonInfo[moonIndex].position + Vector3::getRandomUnitVector() * (moonInfo[moonIndex].radius + 500.0); ships[i].initPhysics(s_id, pos, 100.f, Vector3::getRandomUnitVector(), s_dl, 1.f); ships[i].setHealth(1); ships[i].setAmmo(0); ships[i].setSpeed(0.f); } // Add Bullets ObjModel b; b.load("Models/Bolt.obj"); DisplayList b_dl = b.getDisplayList(); for (int i = 0; i < BULLET_COUNT; i++) { PhysicsObjectId b_id = PhysicsObjectId(PhysicsObjectId::TYPE_BULLET, PhysicsObjectId::FLEET_MAX, i); bullets[i].initPhysics(b_id, {0, 0, 0}, 1.f, {0, 0, 0}, b_dl, 2.5f); } assert(mp_explosion_manager != NULL); mp_explosion_manager->init("Explode1.png", 15); } assert(invariant()); }
void init() { initDisplay(); bucket.load("firebucket.obj"); bucket_list = bucket.getDisplayList(); }