Exemple #1
0
	void HexagonGame::incrementDifficulty()
	{
		playSound("levelUp.ogg");

		setRotationSpeed(levelData.getRotationSpeed() + levelData.getRotationSpeedIncrement() * getSign(getRotationSpeed()));
		setRotationSpeed(levelData.getRotationSpeed() * -1);

		if(status.fastSpin < 0 && abs(getRotationSpeed()) > levelData.getValueFloat("rotation_speed_max"))
			setRotationSpeed(levelData.getValueFloat("rotation_speed_max") * getSign(getRotationSpeed()));

		status.fastSpin = levelData.getFastSpin();
	}
void HexagonGame::update(float mFrameTime)
{
    if(!hasDied)
    {
        manager.update(mFrameTime);

        updateLevelEvents(mFrameTime);

        if(timeStop <= 0)
        {
            currentTime += mFrameTime / 60.0f;
            incrementTime += mFrameTime / 60.0f;
        }
        else timeStop -= 1 * mFrameTime;

        updateIncrement();
        updateLevel(mFrameTime);
        updateRadius(mFrameTime);
        if(!getBlackAndWhite()) styleData.update(mFrameTime);
    }
    else setRotationSpeed(getRotationSpeed() / 1.001f);

    updateKeys();
    if(!getNoRotation()) updateRotation(mFrameTime);

    if(mustRestart) newGame(levelData.getId(), false);
}
void HexagonGame::incrementDifficulty()
{
    playSound("level_up");

    setSpeedMultiplier(getSpeedMultiplier() + levelData.getSpeedIncrement());
    setRotationSpeed(getRotationSpeed() + levelData.getRotationSpeedIncrement());
    setDelayMultiplier(getDelayMultiplier() + levelData.getDelayIncrement());
    rotationDirection = !rotationDirection;
    fastSpin = levelData.getFastSpin();

    if(randomSideChangesEnabled) timeline.add(new Do([&] { randomSideChange(); }));
}
Exemple #4
0
//==============================================================================
// Constructors/Deconstructors
//==============================================================================
Galaxy::Galaxy(dirnode *r, list<filenode*> *f, cluster_type m, string n, list<string>* t)
{
	cout << "making a galaxy...\n";
	
	if (r != NULL)
		setDirectory(r);
	else
	{
		root = NULL;
		files = f;
	}
	
	if (root != NULL && n == "")
		name = root->path + root->name;
	else
		name = n;
	
	xPos = 0;
	yPos = 0;
	side = 0;
		
	diameter = 64.0 * pow((3.0*(double)files->size())/(4.0*M_PI),(1.0/3.0));
	radius = diameter/2;
	thickness = pow(radius*2.0,.5);
	
	setRotation(0,0);
	setRotationSpeed(0.02);
	rotZ = 0;
	
	tags = t;
	if (tags == NULL)
		rebuildTags();
	
	cluster_mode = m;
	
	sectors = NULL;
	selected = NULL;
	buildSectors();
	
	tex_data = NULL;
	initTexture();
	refreshTex();
	
	label = NULL;
	initLabel();
	
	starSelectionLabel = new DrawText(" Star Selection Mode");
	starSelectionLabel->setAlignment(LEFT);
	starSelectionLabel->setTextColor(0,0,0,1);
	starSelectionLabel->refreshTexture();
	
	cout << "galaxy built\n";
}
Exemple #5
0
    ARDrone::ARDrone(std::string sessionId, std::string userId, std::string appId,
                     const std::string ardIp,
                     const unsigned short ardATCmdsPort,
                     const unsigned short ardNavdataPort,
                     const unsigned short ardVideoPort,
                     const unsigned short ardControlPort,
                     ARDroneConnections* connectionHandler,
                     Navdata* navdata,
                     Video* video)
        : m_sessionId(sessionId)
        , m_userId(userId)
        , m_appId(appId)
        , m_ardIp(ardIp)
        , m_ardATCmdsPort(ardATCmdsPort)
        , m_ardNavdataPort(ardNavdataPort)
        , m_ardVideoPort(ardVideoPort)
        , m_ardControlPort(ardControlPort)
        , m_altitudeMax(2.0f)
        , m_verticalSpeed(.7f)
        , m_rotationSpeed(3.0f)
        , m_euler_angle_max(0.26f)
        , m_isWithoutShell(false)
        , m_isOutdoor(false)
        , m_connectionsHandler(connectionHandler)
        , m_indexCmd(1)
        , m_navdata(navdata)
        , m_video(video)
    {
        m_video->setCallbackInitFunc([this]() {this->m_connectionsHandler->sendInitVideoData();});

        AT_CONFIG("custom:session_id", sessionId);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        AT_CONFIG("custom:profile_id", userId);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        AT_CONFIG("custom:application_id", appId);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));

        setAltitudeMax(m_altitudeMax);
        setVerticalSpeed(m_verticalSpeed);
        setRotationSpeed(m_rotationSpeed);
        setSpeed(m_euler_angle_max);
        setIsWithoutShell(false);
        setIsOutdoor(false);

        // Initialize the ARDrone video stream (Codecs, etc..)
        setDefaultConfig();

        initNavdata();
    }
Exemple #6
0
void neptuneLoader()
{
    string modelPath = ASSET_PATH + MODEL_PATH + "/Planet.fbx";
    auto currentGameObject = loadFBXFromFile(modelPath);
    string vsPath = ASSET_PATH + SHADER_PATH + "/textureVS.glsl";
    string fsPath = ASSET_PATH + SHADER_PATH + "/textureFS.glsl";
    currentGameObject->loadShader(vsPath, fsPath);
    currentGameObject->setScale(vec3(0.9f, 0.9f, 0.9f));
    currentGameObject->setPosition(vec3(95.0f, 0.0f, 0.0f));
    
    currentGameObject->setRotationSpeed(vec3(0.0f, -1.0f, 0.0f));
    currentGameObject->setOrbitSpeed(vec3(0.0f, 0.78f, 0.0f));
    
    string texturePath = ASSET_PATH + TEXTURE_PATH + "/NeptuneColourMap.png";
    currentGameObject->loadDiffuseMap(texturePath);
    
    gameObjects.push_back(currentGameObject);
}
Exemple #7
0
void marsLoader()
{
    string modelPath = ASSET_PATH + MODEL_PATH + "/Planet.fbx";
    auto currentGameObject = loadFBXFromFile(modelPath);
  string vsPath = ASSET_PATH + SHADER_PATH + "/specularVS.glsl";
  string fsPath = ASSET_PATH + SHADER_PATH + "/specularFS.glsl";
    currentGameObject->loadShader(vsPath, fsPath);
    currentGameObject->setScale(vec3(0.45f, 0.45f, 0.45f));
    currentGameObject->setPosition(vec3(42.0f, 0.0f, 0.0f));
    
    currentGameObject->setRotationSpeed(vec3(0.0f, -1.0f, 0.0f));
    currentGameObject->setOrbitSpeed(vec3(0.0f, 2.5f, 0.0f));
    
    string texturePath = ASSET_PATH + TEXTURE_PATH + "/MarsColourMap2.png";
    currentGameObject->loadDiffuseMap(texturePath);
    
    gameObjects.push_back(currentGameObject);
}
Exemple #8
0
void earthLoader()
{
    string modelPath = ASSET_PATH + MODEL_PATH + "/Planet.fbx";
    auto currentGameObject = loadFBXFromFile(modelPath);
  string vsPath = ASSET_PATH + SHADER_PATH + "/specularVSTest.glsl";
  string fsPath = ASSET_PATH + SHADER_PATH + "/specularFSTest.glsl";
    currentGameObject->loadShader(vsPath, fsPath);
    currentGameObject->setScale(vec3(0.5f, 0.5f, 0.5f));

    currentGameObject->setPosition(vec3(35.0f, 0.0f, 0.0f));

    currentGameObject->setRotationSpeed(vec3(0.0f, -1.0f, 0.0f));
    currentGameObject->setOrbitSpeed(vec3(0.0f, 3.0f, 0.0f));

    string texturePath = ASSET_PATH + TEXTURE_PATH + "/EarthColourMap.png";
   string tecture2Path = ASSET_PATH + TEXTURE_PATH + "/EarthSpecMap.png";
    currentGameObject->loadDiffuseMap(texturePath);
     currentGameObject->LoadSpecularMap(tecture2Path);
  
    gameObjects.push_back(currentGameObject);
}
Exemple #9
0
	void HexagonGame::newGame(const string& mId, bool mFirstPlay, float mDifficultyMult)
	{
		firstPlay = mFirstPlay;
		setLevelData(getLevelData(mId), mFirstPlay);
		difficultyMult = mDifficultyMult;

		// Audio cleanup
		stopAllSounds();
		playSound("go.ogg");
		stopLevelMusic();
		playLevelMusic();

		// Events cleanup
		clearMessage();

		for(auto eventPtr : eventPtrs) delete eventPtr;
		eventPtrs.clear();

		while(!eventPtrQueue.empty()) { delete eventPtrQueue.front(); eventPtrQueue.pop(); }
		eventPtrQueue = queue<EventData*>{};

		// Game status cleanup
		status = HexagonGameStatus{};
		restartId = mId;
		restartFirstTime = false;
		setSides(levelData.getSides());

		// Manager cleanup
		manager.clear();
		factory.createPlayer();

		// Timeline cleanup
		timeline.clear(); timeline.reset();
		messageTimeline.clear(); messageTimeline.reset();
		effectTimelineManager.clear();

		// FPSWatcher reset
		fpsWatcher.reset();
		if(getOfficial()) fpsWatcher.enable();

		// LUA context cleanup
		if(!mFirstPlay) runLuaFunction<void>("onUnload");
		lua = Lua::LuaContext{};
		initLua();
		runLuaFile(levelData.getValueString("lua_file"));
		runLuaFunction<void>("onLoad");

		// Random rotation direction
		if(getRnd(0, 100) > 50) setRotationSpeed(getRotationSpeed() * -1);

		// Reset zoom
		overlayCamera.setView({{getWidth() / 2.f, getHeight() / 2.f}, sf::Vector2f(getWidth(), getHeight())});
		backgroundCamera.setView({{0, 0}, {getWidth() * getZoomFactor(), getHeight() * getZoomFactor()}});
		backgroundCamera.setRotation(0);

		// 3D Cameras cleanup
		depthCameras.clear();
		unsigned int depth{styleData.get3DDepth()};
		if(depth > get3DMaxDepth()) depth = get3DMaxDepth();
		for(unsigned int i{0}; i < depth; ++i) depthCameras.push_back({window, {}});
	}
  NxI32 CommandCallback(NxI32 token,NxI32 count,const char **arglist)
  {
  	NxI32 ret = 0;

    saveMenuState();

		switch ( token )
		{
      case MC_MEMORY_REPORT:
        break;

      case MC_FLOATING_POINT_RESOLUTION:
        if ( count == 2 )
        {
          MultiFloatType type = MFT_MEDIUM;
          if ( stricmp(arglist[1],"SMALL") == 0 )
            type = MFT_SMALL;
          else if ( stricmp(arglist[1],"MEDIUM") == 0 )
            type = MFT_MEDIUM;
          else if ( stricmp(arglist[1],"BIGFLOAT") == 0 )
            type = MFT_BIG;
          else if ( stricmp(arglist[1],"FIXED32") == 0 )
            type = MFT_FIXED32;
          tf_setFloatingPointResolution(gTfrac,type);
          gLog->Display("Setting Floating Point Resolution to: %s\r\n", arglist[1] );
        }
        break;
      case MC_SHOW_NORMALS:
        if ( count == 2 )
        {
          setShowNormals( getBool(arglist[1]) );
        }
        break;
      case MC_ENVIRONMENT_TEXTURE:
        if ( count == 2 )
        {
          const char *t = arglist[1];
          if ( gFileSystem ) t = gFileSystem->FileOpenString(t,true);
          gPd3d->setEnvironmentTexture(t);
        }
        break;
      case MC_ROTATION_SPEED:
        if ( count == 2 )
        {
          NxF32 rspeed = (NxF32)atof( arglist[1] );
          setRotationSpeed(rspeed);
        }
        break;
		  case MC_OPTIMIZE_MESH:
				if ( !mStartup )
				{
					tf_state(gTfrac,TS_OPTIMIZE_MESH);
				}
				break;
      case MC_FILTER_FRACTAL:
        if ( !mStartup )
        {
          tf_state(gTfrac,TS_FILTER_FRACTAL);
        }
        break;
      case MC_DEFAULT_MANDELBROT:
				if ( !mStartup )
				{
          BigFloat xleft;
          BigFloat xright;
          BigFloat ytop;
          xleft.FromDouble(-2.5);
          xright.FromDouble(0.75);
          ytop.FromDouble(-1.5);
          tf_setFractalCoordinates(gTfrac,xleft,xright,ytop);
          tf_action(gTfrac,FA_MOUSE_CENTER,false,1024/2,768/2);
				}
        break;
      case MC_CLAMP_LOW:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_LOW,false,0,c);
        }
        break;
      case MC_CLAMP_HIGH:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_HIGH,false,0,c);
        }
        break;
      case MC_CLAMP_SCALE:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_SCALE,false,0,c);
        }
        break;
      case MC_WIREFRAME_OVERLAY:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_WIREFAME_OVERLAY,state);
        }
        break;
      case MC_VIEW3D:
        if ( count == 2 )
        {
					gView3d = getBool(arglist[1]);
          if ( gView3d )
          {
            NxF32 eye[3];
            NxF32 look[3];
            look[0] = 0;
            look[1] = 0;
            look[2] = 0;
            eye[0] = 200;
            eye[1] = 250;
            eye[2] = 200;
            lookAt(eye,look);
          }
        }
        break;
      case MC_FRACTAL_COORDINATES:
        if ( count == 4 && gTfrac )
        {
          BigFloat xleft =  arglist[1];
          BigFloat xright = arglist[2];
          BigFloat ytop   = arglist[3];
          tf_setFractalCoordinates(gTfrac,xleft,xright,ytop);
        }
        break;
      case MC_COLOR_PALETTE:
        if ( count == 2 && gTfrac )
        {
          tf_setPal(gTfrac,arglist[1]);
        }
        break;
		  case MC_ITERATION_COUNT:
				if ( count == 2 && gTfrac )
				{
					NxU32 icount = (NxU32)atoi(arglist[1]);
					tf_state(gTfrac,TS_ITERATION_COUNT,false,icount);
				}
				break;
		  case MC_CLOCK_CYCLES:
				if ( count == 2 && gTfrac )
				{
					NxU32 icount = (NxU32)atoi(arglist[1]);
					tf_state(gTfrac,TS_CLOCK_CYCLES,false,icount);
				}
				break;
			case MC_USE_THREADING:
				if ( count == 2 && gTfrac )
				{
					bool state = getBool(arglist[1]);
  			  tf_state(gTfrac,TS_THREADING,state);
  			}
				break;

			case MC_SMOOTH_COLOR:
				if ( count == 2 && gTfrac )
				{
					NxI32 cscale  = atoi(arglist[1]);
					tf_state(gTfrac,TS_SMOOTH_COLOR,false,cscale);
				}
				break;

      case MC_PREVIEW_ONLY:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_PREVIEW_ONLY,state);
        }
        break;
			case MC_RECTANGLE_SUBDIVISION:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_RECTANGLE_SUBDIVISION,state);
        }
        break;
			case MC_PSLOOKAT:
				//            0      1      2      3       4      5       6
				// Usage: PsLookAt <eyex> <eyey> <eyez> <lookx> <looky> <lookz>
				if ( count == 7 )
				{
					NxF32 eye[3];
					NxF32 look[3];

					eye[0] = (NxF32) atof( arglist[1] );
					eye[1] = (NxF32) atof( arglist[2] );
					eye[2] = (NxF32) atof( arglist[3] );

					look[0] = (NxF32) atof(arglist[4] );
					look[1] = (NxF32) atof(arglist[5] );
					look[2] = (NxF32) atof(arglist[6] );

					lookAt(eye,look);

				}
				break;
			case MC_PSSCRIPT:
				{
					const char *fname = 0;
					if ( count >= 2 )
					{
						fname = arglist[1];
					}
#if TODO
  				SoftFileInterface *sfi = gSoftBodySystem->getSoftFileInterface();
  				if ( sfi )
  				{
  					fname = sfi->getLoadFileName(".psc", "Select a demo script to run.");
  				}
  				if ( fname )
  				{
  					CPARSER.Parse("Run \"%s\"",fname);
  				}
#endif
				}
				break;
		}


    return ret;
  }
BasicScreenObject::BasicScreenObject(){
		
	masktype= MASK_TYPE_CLIPPLANES;
	ismask	= false;
	hasmask	= false;
	
	setPosition(0,0,0);
	speed.set(0,0,0);
	accel.set(0,0,0);
	moveattractionforce	= 0;
	movedrag			= 1;
	
	setScale(1, 1, 1);
	width = height = 10;
	
	alpha		= 255;
	setColor(255,255,255);
	tweenr		= 255;
	tweeng		= 255;
	tweenb		= 255;
	isColorTweening	= false;
	isFadeTweening	= false;
	isFadeTweeningToInvisible = false;
	
	// Rotation
	rotationdrag = 0.99;
	rotationspeed.set(0,0,0);
	
	setRotationSpeed(0, 0, 0);
	setRotationDrag(0.99);
	rotationattractionforce = 0;
	rotationattractionquat.set(0,0,0,1);
	rotationattractionangles.set(0,0,0);
	
	isRotationTweening = false;
	
	lightingbefore		= false;
	lightingenabled		= false;
	depthtestbefore		= false;
	depthtestenabled	= false;
	
	
	age					= 0;
	_isAddedToRenderer	= false;
	issetup				= false; // TODO: issetup needed??

	
	parent_so	= NULL;
	root		= NULL;

	myEventArgs.target = this;
	
	sfactor		= GL_SRC_ALPHA;
	dfactor		= GL_ONE_MINUS_SRC_ALPHA;
		
	tweenx			= 0;
	tweeny			= 0;
	tweenz			= 0;
	isMoveTweening	= false;
	isSizeTweening	= false;
	
	tweenscalex		= 0;
	tweenscaley		= 0;
	tweenscalez		= 0;
	tweenrotslerp	= 0.0;
	isScaleTweening = false;
	
	isvisible				= true;
	_isParentTreeVisible	= true;
	isorderbyz				= false;
	isupdating				= true;
	
	isRenderer				= false;
	
	ofAddListener(ofEvents().setup,		this, &BasicScreenObject::_setup);
	ofAddListener(ofEvents().update,	this, &BasicScreenObject::_update);
	ofAddListener(ofEvents().exit,		this, &BasicScreenObject::_exit);
	ofAddListener(killEvent,	this, &BasicScreenObject::onKill);
	ofAddListener(hideEvent,	this, &BasicScreenObject::onHide);
	ofAddListener(showEvent,	this, &BasicScreenObject::onShow);
	ofAddListener(Tweener.onTweenCompleteEvent, this, &BasicScreenObject::onTweenComplete);
}