Sim::Sim() : sim::Sim(), _arena(0) { #if ODE == 1 DBG("Using ODE"); sim::ode::World *w = new sim::ode::World(); setWorld(w); w->setCFM(.0001); w->setERP(0.8); w->setStepType(sim::ode::World::STEP_TYPE_QUICK); w->setAutoDisable(0.01, 0.01, 5, 0.); w->setContactApprox1(true); w->setContactApprox2(true); w->setContactBounce(0.1, 0.1); #else DBG("Using Bullet"); sim::bullet::World *w = new sim::bullet::World(); setWorld(w); #endif setTimeStep(sim::Time::fromMs(5)); setTimeSubSteps(2); pauseSimulation(); setSimulateReal(false); _povray = 0; createArena(); createRobots(); }
gint main(gint argc, gchar* argv[]){ char* hw = "`r```````````.H.e.l.l.o. .w.o.r.l.di"; char* fib = "```s``s``sii`ki\n" "`k.*``s``s`ks\n" "``s`k`s`ks``s``s`ks``s`k`s`kr``s`k`sikk\n" "`k``s`ksk"; /* * http://www.madore.org/~david/programs/unlambda/ */ World* world; UnlambdaEval* ue; GOptionContext *context; GError *error = NULL; context = g_option_context_new("This line is appeared after Uagese's command line"); g_option_context_set_summary(context, "This line is appeared before options"); g_option_context_set_description(context, "This line is appeared after options"); if(!g_option_context_parse(context, &argc, &argv, &error)){ g_printerr("option parsing failed: %s\n", error->message); return 1; } world = CreateWorld(MAXOBJECTS); setWorld(world); ue = NewUnlambdaEval(world); printf("%s\n", fib); //eval(hw); UnlambdaEval_eval(ue, fib); DeleteWorld(world); return 0; }
void Core::setWorld(const json& r) { if (!m_world) m_world = new World(r); else m_world->deserialize(r); setWorld(m_world); }
void PNS_DIFF_PAIR_PLACER::initPlacement() { m_idle = false; m_orthoMode = false; m_currentEndItem = NULL; m_startDiagonal = m_initialDiagonal; PNS_NODE* world = Router()->GetWorld(); world->KillChildren(); PNS_NODE* rootNode = world->Branch(); setWorld( rootNode ); m_lastNode = NULL; m_currentNode = rootNode; m_currentMode = Settings().Mode(); if( m_shove ) delete m_shove; m_shove = NULL; if( m_currentMode == RM_Shove || m_currentMode == RM_Smart ) { m_shove = new PNS_SHOVE( m_currentNode, Router() ); } }
Chunk::Chunk(const Chunk &chunk) { setWorld(chunk.getWorld()); setLoc(chunk.getLoc()); const unsigned char *blocks = chunk.getBlocks(); memcpy(m_Blocks, blocks, CHUNK_WIDTH * CHUNK_WIDTH * CHUNK_HEIGHT); }
//---------------------------------------- void ofxBox2dRevoluteJoint::setup(b2World* b2world, b2RevoluteJointDef jointDef) { setWorld(b2world); joint = (b2RevoluteJoint*)world->CreateJoint(&jointDef); alive = true; }
/***************************************************************************\ * Class Specific * \***************************************************************************/ void PhysicsHinge2Joint::initHinge2Joint() { setAnchor(PhysicsHinge2JointBase::getAnchor()); setAxis1(PhysicsHinge2JointBase::getAxis1()); setAxis2(PhysicsHinge2JointBase::getAxis2()); setWorld(PhysicsHinge2JointBase::getWorld()); initJoint(); }
ICommand::Handle UserRequestBuilder::buildCreateWorldRequest ( const std::string a_world_name ) { setWorld(a_world_name); return mReqBuilder->buildCreateWorldRequest( mUsername, mPassword, mWorld ); }
//---------------------------------------- void ofxBox2dWeldJoint::setup(b2World* b2world, b2Body* body1, b2Body* body2, b2Vec2 anchor, bool bCollideConnected) { setWorld(b2world); b2WeldJointDef jointDef; jointDef.Initialize(body1, body2, anchor); jointDef.collideConnected = bCollideConnected; joint = (b2WeldJoint*)world->CreateJoint(&jointDef); alive = true; }
bool PNS_DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { VECTOR2I p( aP ); if( !aStartItem ) { Router()->SetFailureReason( _( "Can't start a differential pair " " in the middle of nowhere." ) ); return false; } setWorld( Router()->GetWorld() ); m_currentNode = m_world; if( !findDpPrimitivePair( aP, aStartItem, m_start ) ) { Router()->SetFailureReason( _( "Unable to find complementary differential pair " "net. Make sure the names of the nets belonging " "to a differential pair end with either _N/_P or +/-." ) ); return false; } m_netP = m_start.PrimP()->Net(); m_netN = m_start.PrimN()->Net(); #if 0 // FIXME: this also needs to be factored out but not so important right now // Check if the current track/via gap & track width settings are violated BOARD* brd = NULL; // FIXME Router()->GetBoard(); NETCLASSPTR netclassP = brd->FindNet( m_netP )->GetNetClass(); NETCLASSPTR netclassN = brd->FindNet( m_netN )->GetNetClass(); int clearance = std::min( m_sizes.DiffPairGap(), m_sizes.DiffPairViaGap() ); if( clearance < netclassP->GetClearance() || clearance < netclassN->GetClearance() ) { Router()->SetFailureReason( _( "Current track/via gap setting violates " "design rules for this net." ) ); return false; } if( m_sizes.DiffPairWidth() < brd->GetDesignSettings().m_TrackMinWidth ) { Router()->SetFailureReason( _( "Current track width setting violates design rules." ) ); return false; } #endif m_currentStart = p; m_currentEnd = p; m_placingVia = false; m_chainedPlacement = false; initPlacement(); return true; }
//---------------------------------------- void ofxBox2dJoint::setup(b2World* b2world, b2Body* body1, b2Body* body2, b2Vec2 anchor1, b2Vec2 anchor2, float frequencyHz, float damping, bool bCollideConnected) { setWorld(b2world); b2DistanceJointDef jointDef; jointDef.Initialize(body1, body2, anchor1, anchor2); jointDef.collideConnected = bCollideConnected; jointDef.frequencyHz = frequencyHz; jointDef.dampingRatio = damping; joint = (b2DistanceJoint*)world->CreateJoint(&jointDef); alive = true; }
void Engine::init(const sf::VideoMode& videoMode, const std::string& title, int frameRateLimit, World* world, sf::Uint32 style, const sf::ContextSettings& settings, bool vsync) { window = new sf::RenderWindow(videoMode, title, style, settings); window->setVerticalSyncEnabled(vsync); window->setFramerateLimit(frameRateLimit); camera.setCenter(videoMode.width / 2, videoMode.height / 2); camera.setSize(videoMode.width, videoMode.height); setWorld(world); run(); }
//---------------------------------------- void ofxBox2dDistanceJoint::setup(b2World *w, b2Body *body1, b2Body *body2, float frequencyHZ, float dampingRatio, bool bCollideConnected){ setWorld(w); b2DistanceJointDef jointDef; jointDef.Initialize(body1, body2, body1->GetWorldCenter(), body2->GetWorldCenter()); jointDef.collideConnected = bCollideConnected; jointDef.frequencyHz = frequencyHZ; jointDef.dampingRatio = dampingRatio; joint = (b2DistanceJoint*)world->CreateJoint(&jointDef); alive = true; }
void ofxBox2dJoint::setup(b2World* b2world, b2Body* body1, b2Body* body2, ofVec2f anchor1, ofVec2f anchor2, float frequencyHz, float damping, bool bCollideConnected) { setWorld(b2world); b2DistanceJointDef jointDef; anchor1 /= OFX_BOX2D_SCALE; anchor2 /= OFX_BOX2D_SCALE; jointDef.Initialize(body1, body2, b2Vec2(anchor1.x, anchor1.y), b2Vec2(anchor2.x, anchor2.y)); jointDef.collideConnected = bCollideConnected; jointDef.frequencyHz = frequencyHz; jointDef.dampingRatio = damping; joint = (b2DistanceJoint*)world->CreateJoint(&jointDef); alive = true; }
//---------------------------------------- void ofxBox2dLineJoint::setup(b2World* b2world, b2Body* body1, b2Body* body2, b2Vec2 anchor, b2Vec2 axis, float lowerTranslation, float upperTranslation, float maxMotorForce, float motorSpeed, bool enableLimit, bool enableMotor, bool bCollideConnected) { setWorld(b2world); b2LineJointDef ljointDef; ljointDef.Initialize(body1, body2, anchor, axis); ljointDef.lowerTranslation = lowerTranslation; ljointDef.upperTranslation = upperTranslation; ljointDef.maxMotorForce = maxMotorForce; ljointDef.motorSpeed = motorSpeed; ljointDef.enableLimit = enableLimit; ljointDef.enableMotor = enableMotor; ljointDef.collideConnected = bCollideConnected; ljoint = (b2LineJoint*)world->CreateJoint(&ljointDef); alive = true; }
/* GENERAL */ void SimpleColorEffect::init(const VertexLayout& layout) { Material* mat(CONTENT->loadMaterial("engine/2D/color.hm")); m_Material = mat->createMaterialInstance(eShaderRenderType_Normal); mat->release(); m_Material->calculateMaterialLayout(layout); m_ViewProj = m_Material->findParameter(HEFS::strmatVP); m_World = m_Material->findParameter(HEFS::strmatW); m_Color = m_Material->findParameter(HEFS::strcolor); setViewProjection(mat44::Identity); setWorld(mat44::Identity); setColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); }
//---------------------------------------- void ofxBox2dRevJoint::setup(b2World* b2world, b2Body* body1, b2Body* body2, b2Vec2 anchor, float referenceAngle, float lowerAngle, float upperAngle, float maxMotorTorque, float motorSpeed, bool enableLimit, bool enableMotor, bool bCollideConnected) { setWorld(b2world); b2RevoluteJointDef rjointDef; rjointDef.Initialize(body1, body2, anchor); rjointDef.referenceAngle = referenceAngle; rjointDef.lowerAngle = lowerAngle; rjointDef.upperAngle = upperAngle; rjointDef.maxMotorTorque = maxMotorTorque; rjointDef.motorSpeed = motorSpeed; rjointDef.enableLimit = enableLimit; rjointDef.enableMotor = enableMotor; rjointDef.collideConnected = bCollideConnected; rjoint = (b2RevoluteJoint*)world->CreateJoint(&rjointDef); alive = true; }
GraphAxle::GraphAxle( double scaleBeg, double scaleEnd, const QPen &axlePen ) { QColor color( Qt::black ); QPen pen( color, 1, Qt::SolidLine ); QFont font( "Times NEw Roman", 12, QFont::Normal, false ); // The following completely define an GraphAxle & initialize all members. setGraphAxle( scaleBeg, scaleEnd, axlePen ); setWorld( 0, 0, 0, 0 ); setMajorGrid( pen, 0. ); setMajorTics( GraphAxleLeft, 0., 0., 0., 0., pen ); setMajorLabels( font, color, -1 ); setMinorGrid( pen, 0. ); setMinorTics( GraphAxleLeft, 0., 0., 0., 0., pen ); setSubTitle( "", GraphAxleLeft, font, color ); setTitle( "", GraphAxleLeft, font, color ); return; }
//---------------------------------------- void ofxBox2dPulleyJoint::setup(b2World *w, b2Body *body1, b2Body *body2, const b2Vec2 &groundAnchor1, const b2Vec2 &groundAnchor2, const b2Vec2 &anchor1, const b2Vec2 &anchor2, float ratio, bool bCollideConnected){ setWorld(w); b2PulleyJointDef jointDef; jointDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio); jointDef.collideConnected = bCollideConnected; joint = (b2PulleyJoint*)world->CreateJoint(&jointDef); alive = true; }
//---------------------------------------- void ofxBox2dRevoluteJoint::setup(b2World *w, b2Body *body1, b2Body *body2, b2Vec2 anchor, float lowerLimitRadian, float upperLimitRadian, bool bEnableLimit, float motorSpeed, float maxMotorTorque, bool bEnableMotor, bool bCollideConnected){ setWorld(w); b2RevoluteJointDef jointDef; jointDef.Initialize(body1, body2, anchor); jointDef.collideConnected = bCollideConnected; jointDef.lowerAngle = lowerLimitRadian; jointDef.upperAngle = upperLimitRadian; jointDef.enableLimit = bEnableLimit; jointDef.motorSpeed = motorSpeed; jointDef.maxMotorTorque = maxMotorTorque; jointDef.enableMotor = bEnableMotor; joint = (b2RevoluteJoint*)world->CreateJoint(&jointDef); alive = true; }
/*notice the default arguments for main. SDL expects main to look like that, so don't change it*/ int main(int argc, char *argv[]) { // SDL_Surface *temp = NULL; int done;// the player const Uint8 *keys;// the player /* This section starts by loading the BG as a surface and converting it to a texture This will have to change if I can manage to scroll the trexture arond the player*/ SDL_CreateWindowAndRenderer(800, 600, SDL_WINDOW_RESIZABLE, &mainWindow, &renderer); SDL_SetWindowTitle(mainWindow, "Nitro Hotness"); if( TTF_Init() == -1 ) { return false; } if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) { return false; } InitSpriteSystem(); InitEntitySystem(entityMax); map mymap = setWorld(); ObstacleList ol = newObstacleList(); mew = newPlayer(); Obstacle Doh = newObstacle(0); Road_M Path = initRoad(); AI rival = new_AI(); GUI HUD = InitGUI(); mew.position=0; done = 0; //The music that will be played Mix_Music *music = NULL; Mix_Chunk *buzz = NULL; buzz = Mix_LoadWAV( "sfx/buzz.wav" ); readSave(&mew); showTitle(); showMain(); oldTime = 0; currentTime = 0; mytime = 0; do { oldTime = 0; currentTime = 0; mytime = 0; if( Mix_PlayingMusic() == 0 ) { //Play the music if( Mix_PlayMusic( level_music, -1 ) == -1 ) { return 1; } } SDL_Event e; SDL_PollEvent( &e ); if(&e) { //User requests quit if( e.type == SDL_QUIT ) { done = 1; } //user presses enter to go to next menu //User presses a key else if( e.type == SDL_KEYDOWN ) { //Select surfaces based on key press switch( e.key.keysym.sym ) { case SDLK_LEFT: // slog("left is down"); mew.playerX += 3; mew.accel = (mew.accel - .000001); break; case SDLK_RIGHT: // slog("right is down"); mew.playerX -= 3; mew.accel = (mew.accel - .000001); break; case SDLK_UP: // slog("up is down"); mew.accel = (mew.accel + .00007); Mix_PlayChannel( 1, buzz, 0 ); break; case SDLK_DOWN: // slog("down is down"); mew.accel = (mew.accel - .00008); break; } } else if( e.type == SDL_KEYUP ) { //Select surfaces based on key press switch( e.key.keysym.sym ) { case SDLK_RETURN : if(mew.done ==1) { Mix_HaltMusic(); if(GP == 1) { mew.done=0; lvl++; //slog("new level is %i",lvl); mew.position = 0; rival.position =0; setWorld(); Results(mew.rank,lvl); } else if (GP == 0) { mew.done=0; mew.position = 0; rival.position =0; levelSelect(); } } else { slog("too soon"); } case SDLK_LEFT: // slog("left is up"); e.type = SDLK_CLEAR; break; case SDLK_RIGHT: // slog("right is up"); e.type = SDLK_CLEAR; break; case SDLK_UP: // slog("up is up"); mew.accel = (mew.accel - .001); Mix_HaltChannel(1); e.type = SDLK_CLEAR; break; case SDLK_DOWN: // slog("down is up"); mew.accel = 0; e.type = SDLK_CLEAR; break; default: //slog("simple decel"); mew.accel = (mew.accel-0.00001); break; } } if(mew.position > rival.position) { mew.rank = 1 ; } else if( rival.position > mew.position ) { mew.rank = 2 ; } SDL_RenderClear(renderer); DrawBG(BG1,BG2); roadUpdate(Path,mymap,mew); roadDraw(Path,mymap,&mew); roadFetch(Path,mymap,&mew); checkForObstacles(ol , &mew, Doh); update_AI(&rival, &mew); UpdatePlayer(&mew); DrawGui(HUD,mew); NextFrame(); keys = SDL_GetKeyboardState(NULL); if(keys[SDL_SCANCODE_ESCAPE]) { done = 1; } } }while(!done); //Free the sound effects //Free the music Mix_FreeMusic( music ); CloseEntitySystem(); CloseSpriteSystem(); exit(0); /*technically this will end the program, but the compiler likes all functions that can return a value TO return a value*/ return 0; }
void TestTracker::enterWorld( const WorldDescription &wd ) { setWorld( &wd ); _warnings = _failedTests = _testFailedAsserts = _suiteFailedTests = _failedSuites = 0; _l->enterWorld( wd ); }
void TestTracker::leaveWorld( const WorldDescription &wd ) { _l->leaveWorld( wd ); setWorld( 0 ); }
int main(int argc, char* argv[]) { int seed = init_rand(); //int seed = init_rand(1314485160); std::cout << "seed:" << seed << std::endl; initScreen(); displayTitleScreen(); int world_width = worldScreenDims[WIDTH]; int world_height = worldScreenDims[HEIGHT]; int world_depth = 5; world = new World(world_width, world_height, world_depth); setWorld(world);//interface.h, just to keep a pointer to the world so It doesn't have to get passed with every message, prompt, etc. probably a better way to do this but i cba player = world->generatePlayer(); enemies = world->generateEnemies(4,8); world->generateItems(25,50); std::stringstream intro_stream; intro_stream << "You are " << player->getName() << ", an Adventurer in search of the Icon of Weedaula."; message(intro_stream.str()); message("Bring the Icon back to the surface to win the game!"); message("Press '?' for help"); while (!isGameOver()) { world->incrementTimeStep(); player->FOV(player->getMapLevel()); displayGameScreen(); updateScreen(); player->startTurn(); while (!player->isTurnFinished() && player->isTurn() && !isGameOver()) { handleKeyPress(); } player->endTurn(); enemies = world->getEnemyList(); for (unsigned int i = 0; i < enemies.size(); i++) { Enemy *en = enemies[i]; en->FOV(en->getMapLevel()); en->startTurn(); if (en->isTurn() && withinRange(en->getMapLevel(), player->getMapLevel(), player->getMapLevel())) { en->takeTurn(); } en->endTurn(); } } if (isGameOver()) { if (!player->isAlive()) { displayGameOverScreen("You have been struck down"); } } }
void EditorToolBar::create(World *_world) { // Get rid of everything old destroy(); // Attach to the game world setWorld(_world); // Create the World properties panel toolBarZone = new ListPaneWidget(0, 10); toolBarZone->m_bVisible = false; AddChild(toolBarZone); // Populate the World properties panel toolBarZone->addElement(new ListElementTweaker<float>( "Ambient Light [0,1]", &(world->getLightManager().ambientLight) )); toolBarZone->addElement(new ListElementTweakerString( "World Name", &(world->name) )); // Create the Tools panel toolBarTools = new ToolBarForEditorTools(0, 160); toolBarTools->m_bVisible = false; AddChild(toolBarTools); // Create the misc toolbar toolBarMisc = new ListPaneWidget(64, 160); toolBarMisc->m_bVisible = false; AddChild(toolBarMisc); // Populate the misc toolbar toolBarMisc->addElement(new ToggleWidget(&snapToGrid, "data/sprites/list/editor/snap_on.png", "data/sprites/list/editor/snap_off.png")); toolBarMisc->addElement(new ToggleWidget(&shouldSave, "data/sprites/list/editor/save_down.png", "data/sprites/list/editor/save_up.png")); toolBarMisc->addElement(new ToggleWidget(&shouldLoad, "data/sprites/list/editor/load_down.png", "data/sprites/list/editor/load_up.png")); toolBarMisc->addElement(new ToggleWidget(&shouldNew, "data/sprites/list/editor/new_on.png", "data/sprites/list/editor/new_on_over.png", "data/sprites/list/editor/new_off.png", "data/sprites/list/editor/new_off_over.png")); // Create some controls for the map editor createObjectPalette(); createWallTextureSelector(); createFloorTextureSelector(); createTileTypeSelector(); createTileHeightSelector(); // Create the tile properties page toolBarTilePropreties = new ListPaneWidget(1024-341, 235); toolBarTilePropreties->m_bVisible = false; AddChild(toolBarTilePropreties); toolBarTilePropreties->addElement(new CycleTextureSelectorState(&textureSelectorState)); toolBarTilePropreties->addElement(new ToggleWidgetText ("Select Type", &(tileTypeSelector->m_bVisible))); //toolBarTilePropreties->addElement(new ToggleWidgetText ("Select Height", &(tileHeightSelector->m_bVisible))); toolBarTilePropreties->addElement(new ListElementTweaker<TILE_PROPERTIES> ("Tile Properties", &tileEditor_properties)); toolBarTilePropreties->addElement(new ListElementTweaker<float> ("Tile Height", &tileEditor_height)); // Create the mouse cursor label mousePosLabel = new LabelWidget("label here", vec2(700,700)); AddChild(mousePosLabel); // Create the actor properties pane actorProperties = new ListPaneWidget(400, 400); AddChild(actorProperties); hideActorPane(); // initially hidden }
Chunk::~Chunk() { setWorld(0); }
/**abstrac simulator implementation*/ void Simulator::prepareSimulation( World & w) { mobiles.clear(); setWorld( w ); }
Sampler::Sampler(World *world){ setWorld(world); }