コード例 #1
0
Vector3 GetNaturalSize( Actor actor )
{
  Vector3 size = actor.GetCurrentSize();
  const float depth = size.depth;

  // Get natural size for TextActor.
  TextActor textActor = TextActor::DownCast( actor );
  if( textActor )
  {
    Font font = textActor.GetFont();
    if( !font )
    {
      font = Font::New();
    }
    size = font.MeasureText( textActor.GetText() );
    size.depth = depth;
  }

  // Get natural size for ImageActor.
  // TODO: currently it doesn't work as expected.
  ImageActor imageActor = ImageActor::DownCast( actor );
  if( ( imageActor ) && ( imageActor.GetImage() ) )
  {
    Image image = imageActor.GetImage();
    size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
  }

  return size;
}
コード例 #2
0
void DemoScreenConsole::Start()
{
	//Place the actor from a definition file
	localActor = a = Actor::Create("simple_actor");
	theWorld.Add(a);
	
	//Give it a name that our script hooks can latch onto. 
	a->SetName("ForDemoConsole");







	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	String explanation = "This demo shows off the console.";
	explanation += "\n\nPress ~ to open it up. Execute \"add_texture()\", enjoying the tab-completion.";
	explanation += "\nThen try executing \"change_size(3.14)\" or whatever number suits your fancy.";
	explanation += "\n\nThe console is a (nearly) fully functional Python interpreter.";
	explanation += "\nThe sample functions are defined in \"Resources/Scripts/client_start.py\".";
	t = new TextActor("Console", explanation);
	t->SetPosition(0, -3.5f);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenConsole.cpp, demo_actors.ini, client_start.py");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(a);
	#pragma endregion
}
コード例 #3
0
float GetHeightForWidth( Actor actor, float width )
{
  Vector3 size = actor.GetCurrentSize();
  float height = 0.f;

  TextActor textActor = TextActor::DownCast( actor );
  if( textActor )
  {
    Font font = textActor.GetFont();
    if( !font )
    {
      font = Font::New();
    }
    size = font.MeasureText( textActor.GetText() );
  }

  ImageActor imageActor = ImageActor::DownCast( actor );
  if( ( imageActor ) && ( imageActor.GetImage() ) )
  {
    Image image = imageActor.GetImage();
    size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), 0.f );
  }

  height = size.height / ( size.width / width );

  return height;
}
コード例 #4
0
void DemoScreenCollisionLevelFile::Start()
{
	//Loads the file from Config\ActorDef\collisionlevel_demo.lvl
	LoadLevel("collisionlevel_demo");

	//All the magic happens in the level file!





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	t = new TextActor("Console", "These Actors were also placed using a level file.");
	t->SetPosition(0, 4.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t, 10);
	t2 = new TextActor("Console", "Their physics-related properties came from actor definitions.");
	t2->SetPosition(0, -3.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2, 10);
	t3 = new TextActor("Console", "They respond to sound in a data driven way.");
	t3->SetPosition(0, -4.5);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t3, 10);
	t4 = new TextActor("Console", "If the only collision response you need is sound, this is easier.");
	t4->SetPosition(0, -5.5);
	t4->SetAlignment(TXT_Center);
	theWorld.Add(t4, 10);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenCollisionLevelFile.cpp, collisionlevel_demo.lvl,");
	TextActor *fileLoc2 = new TextActor("ConsoleSmall", "      ground_actor.adf, physics_event_actor.adf");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 745));
	fileLoc->SetColor(.3f, .3f, .3f);
	fileLoc2->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc2->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc, 10);
	theWorld.Add(fileLoc2, 10);
	_objects.push_back(fileLoc);
	_objects.push_back(fileLoc2);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(t4);
	ActorSet spawnedActors = tagList.GetObjectsTagged("spawned");
	ActorSet::iterator it = spawnedActors.begin();
	while (it != spawnedActors.end())
	{
		_objects.push_back(*it);
		it++;
	}
	#pragma endregion
}
コード例 #5
0
void CutSceneScreen::Start()
{
	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t = new TextActor("Console", "CutSceneScreen");
	t->SetPosition(0, 0);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "CutSceneScreen.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	m_objects.push_back(fileLoc);
	m_objects.push_back(t);
	#pragma endregion
}
コード例 #6
0
void DemoScreenLayeredCollisionLevelFile::Start()
{
	//Give names to some layers so we can reference them more easily
	theWorld.NameLayer("background", 0);
	theWorld.NameLayer("foreground", 1);
	theWorld.NameLayer("hud", 2);
	
	//Loads the file from Config\ActorDef\layeredcollisionlevel_demo.lua
	theWorld.LoadLevel("layeredcollisionlevel_demo");

	//All the magic happens in the level file!





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	t2 = new TextActor("Console", "These new Actors were assigned layers in their level file.");
	t2->SetPosition(0, 5.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2, 10);
	t3 = new TextActor("Console", "Layers can be given string names as well as numbers");
	t3->SetPosition(0, 4.5);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t3, 10);
	t4 = new TextActor("Console", "and assigned to Actors in their definition file or at runtime.");
	t4->SetPosition(0, 3.5);
	t4->SetAlignment(TXT_Center);
	theWorld.Add(t4, 10);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLayeredCollisionLevelFile.cpp, layeredcollisionlevel_demo.lua");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc, 10);
	_objects.push_back(fileLoc);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(t4);
	ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
	ActorSet::iterator it = spawnedActors.begin();
	while (it != spawnedActors.end())
	{
		_objects.push_back(*it);
		it++;
	}
	#pragma endregion
}
コード例 #7
0
void DemoScreenParticleActors::Start()
{
	// Create the particle actor via the Actor Definition system (.adf files)
	pa = new ParticleActor();
	pa->SetColor(1.0f, 1.0f, 1.0f);  //Sets the initial color of the particles. 
									 // Since the image file we'll be using already
									 // has a color, we set this to pure white. 
	
	pa->SetSize(Vector2(0.2f, 0.2f)); //The size of each particle, in GL units
	pa->SetSprite("Resources/Images/Test.png"); //The image file we want to use (otherwise 
												// it'll just be colored squares).
	pa->SetMaxParticles(500); //The maximum number of particles this system will ever handle. 
	pa->SetParticlesPerSecond(10.0f); //Emission Rate
	pa->SetParticleLifetime(1.5f); //How long each particles lasts before disappearing
	pa->SetSpread(MathUtil::Pi); //The angle in radians at which particles will be emitted. 
	pa->SetEndScale(1.0f); //If you want the particles to change size over their lifetimes
	Color endColor(1.0f, 1.0f, 1.0f, 0.0f);
	pa->SetEndColor(endColor); //Our particles disappear over time
	pa->SetEndScale(2.0f);	
	pa->SetSpeedRange(3.0f, 4.0f); //The minimum and maximum range of speeds (so you can have
								   // some variation).
	pa->SetGravity(Vector2::Zero); //You can pull the particles in a particular direction (default is
								   // downwards, so zero it out if you need to).
	theWorld.Add(pa);

	_isActive = true; //lets the mouse events know that they should care

	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t = new TextActor("Console", "Here's a ParticleActor. (Try moving and clicking the mouse!)");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	t2 = new TextActor("Console", "Press [B] to change its properties.");
	t2->SetPosition(0, 2.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenParticleActors.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(pa);
	#pragma endregion
}
コード例 #8
0
   virtual void Start()
   {
      if( theTTTGame.GetTurn() == Invalid )
         m_square.SetColor( Color3f(0,0,1) );
      else if( theTTTGame.GetTurn() == X )
         m_square.SetColor( Color3f(1,0,0) );
      else
         m_square.SetColor( Color3f(0,1,0) );
      theWorld.Add( &m_square );
		
		TextActor *actor = new TextActor("Console", "Press SPACE to restart");
		actor->SetColor(0,0,0);
		actor->SetPosition(-6, 9);
		actor->SetAlignment(TXT_Center);
		theWorld.Add(actor,3);
		m_objects.push_back(actor);
   }
コード例 #9
0
void DemoScreenMultipleControllers::Start()
{
	//Create two Actors that we're going to manipulate with the two 
	// controllers. All the actual interesting stuff happens in the
	// DemoScreenMultipleControllers::Update function. 
	a = new Actor();
	a->SetSize(4.0f);
	a->SetPosition(-4.0f, 0.0f);
	a->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
	theWorld.Add(a);
	
	a2 = new Actor();
	a2->SetSize(4.0f);
	a2->SetPosition(4.0f, 0.0f);
	a2->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
	theWorld.Add(a2);
	
	
	
	
	//Demo housekeeping below this point. 
#pragma region Demo Housekeeping
	t = new TextActor("Console", "These two actors are connected to different controllers.");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	t2 = new TextActor("Console", "You can use multiple controllers for two-player games.");
	t2->SetPosition(0, -4);
	t2->SetAlignment(TXT_Center);
	t3 = new TextActor("Console", "(If you only have one [or zero] controllers connected, \nthis screen is kind of boring.)");
	t3->SetPosition(0, -8);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t);
	theWorld.Add(t2);
	theWorld.Add(t3);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenMultipleControllers.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(a);
	_objects.push_back(a2);
#pragma endregion
}
コード例 #10
0
void DemoScreenRenderLayers::Start()
{
	//Create overlapping actors
	a1 = new Actor();
	a1->SetSize(5.0f);
	a1->SetColor(0,0,1);
	a1->SetPosition(-1, -1);
	a2 = new Actor();
	a2->SetSize(5.0f);
	a2->SetColor(1,0,0);
	a2->SetPosition(1, 1);


	theWorld.Add(a1, 0); //Adding this actor to layer 0
	theWorld.Add(a2, 1); //Adding this actor to layer 1

	//For your game, you may want to use an enum
	//  or name the layers (see World.cpp or the later
	//  DemoScreenLayeredCollisionLevelFile.cpp for more
	//  information).





	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t1 = new TextActor("Console", "These Actors overlap.");
	t1->SetPosition(0, 5.5);
	t1->SetAlignment(TXT_Center);
	theWorld.Add(t1);
	t2 = new TextActor("Console", "Use the controller's bumper buttons or \nthe right and left arrow keys to change their layer ordering.");
	t2->SetPosition(0, 4.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenRenderLayers.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t1);
	_objects.push_back(t2);
	_objects.push_back(a1);
	_objects.push_back(a2);
	#pragma endregion
}
コード例 #11
0
void dbgPrint( const WordLayoutInfo& word )
{
  for( CharacterLayoutInfoContainer::const_iterator characterIt = word.mCharactersLayoutInfo.begin(), endCharacterIt = word.mCharactersLayoutInfo.end();
       characterIt != endCharacterIt;
       ++characterIt )
  {
    const CharacterLayoutInfo& character( *characterIt );

    std::cout << "[" << character.mSize << std::endl;
    std::cout << " ascender " << character.mAscender << std::endl;

    TextActor textActor = TextActor::DownCast( character.mGlyphActor );
    if( textActor )
    {
      std::cout << "[" << textActor.GetText() << "]";
    }
    else
    {
      std::cout << "[ImageActor]" << std::endl;
    }
    std::cout << "{" << character.mStyledText.mText.GetText() << "}";
  }
  std::cout << "     size " << word.mSize << std::endl;
  std::cout << " ascender " << word.mAscender << std::endl;
  std::cout << " num char " << word.mCharactersLayoutInfo.size() << std::endl;
  std::cout << "     type ";
  switch( word.mType )
  {
    case NoSeparator:
    {
      std::cout << "NoSeparator" << std::endl;
      break;
    }
    case LineSeparator:
    {
      std::cout << "LineSeparator" << std::endl;
      break;
    }
    case WordSeparator:
    {
      std::cout << "WordSeparator" << std::endl;
      break;
    }
  }
}
コード例 #12
0
void DemoScreenRenderLayers::Start()
{
	//Create overlapping actors
	a1 = new Actor();
	a1->SetSize(5.0f);
	a1->SetColor(0,0,1);
	a1->SetPosition(-1, -1);
	a2 = new Actor();
	a2->SetSize(5.0f);
	a2->SetColor(1,0,0);
	a2->SetPosition(1, 1);


	theWorld.Add(a1, 0); //Adding this actor to layer 0
	theWorld.Add(a2, 1); //Adding this actor to layer 1

	//For your game, you will may want to use an
	//  enum for these values so you don't have to
	//  keep the integers straight. 





	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t1 = new TextActor("Console", "These Actors overlap.");
	t1->SetPosition(0, 5.5);
	t1->SetAlignment(TXT_Center);
	theWorld.Add(t1);
	t2 = new TextActor("Console", "Use the controller's bumper buttons to change their layer ordering.");
	t2->SetPosition(0, 4.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenRenderLayers.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t1);
	_objects.push_back(t2);
	_objects.push_back(a1);
	_objects.push_back(a2);
	#pragma endregion
}
コード例 #13
0
ファイル: Shape.cpp プロジェクト: nofxboy1234/sa
void Shape::collectOrb(PhysicsActor* orb) {
  String orb_name = orb->GetName();
  sysLog.Log("Collected Orb: " + orb_name);
  _inventory->add_orb();

  int num_orbs = _inventory->total_orbs();

  String s = "Total orbs: " + IntToString(num_orbs);
  sysLog.Log(s);

  theSound.PlaySound(_orbSound, 1.0f);

  if (num_orbs == 6) {
    TextActor* t = new TextActor("Console", "You beat the game!", TXT_Center);
    Vector2 blocky_pos = GetPosition();
    t->SetPosition(blocky_pos.X, blocky_pos.Y + 5.0f);
    theWorld.Add(t, 2);
  }
}
コード例 #14
0
   virtual void Start()
   {
	   Vector2 fULCorner = MathUtil::ScreenToWorld(0, 0);
	   Vector2 fLRCorner = MathUtil::ScreenToWorld(m_screenWidth, m_screenHeight);
	   Vector2 scrnDims( fabs(fLRCorner.X) + fabs(fULCorner.X), fabs(fLRCorner.Y) + fabs(fULCorner.Y) );

	   float multiplier = 0.8f;
	   float minGridDim = multiplier * MIN(scrnDims.X, scrnDims.Y);

	   float cellSize = minGridDim / float(m_gridSize);	
      theTTTGame.StartGame(cellSize, m_gridSize);    
		theTTTGame.setPlayer1Type(PLAYER1_IS_AI);
		theTTTGame.setPlayer2Type(PLAYER2_IS_AI);
		
		TextActor *actor = new TextActor("Console", "Press SPACE to restart");
		actor->SetColor(0,0,0);
		actor->SetPosition(-6, 9);
		actor->SetAlignment(TXT_Center);
		theWorld.Add(actor,3);
		m_objects.push_back(actor);
   }
コード例 #15
0
void DemoScreenControllerInstructions::Start()
{
	//Some TextActors warning you of the hazards to come. 
	String explanation = "These next two screens show how we get input from an Xbox 360 controller";
	explanation += "\n\nIf you don't have or don't care about the controller, ";
	explanation += "\nthey'll be a little boring. Feel free to skip.";
	TextActor *t = new TextActor("Console", explanation);
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);

	theWorld.Add(t);






	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenControllerInstructions.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	#pragma endregion
}
コード例 #16
0
void DemoScreenByeBye::Start()
{
	//"Goodnight, Gracie."
	TextActor *t = new TextActor("Console", "That's all we've got in the demo app.");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	TextActor *t2 = new TextActor("Console", "Make sure to check out the documentation -- there are lots of other features.\n\nhttp://angel-engine.googlecode.com");
	t2->SetPosition(0, 2);
	t2->SetAlignment(TXT_Center);
	TextActor *t3 = new TextActor("Console", "Press Esc to exit.");
	t3->SetPosition(0, -1);
	t3->SetAlignment(TXT_Center);

	theWorld.Add(t);
	theWorld.Add(t2);
	theWorld.Add(t3);






	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenByeBye.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	#pragma endregion
}
コード例 #17
0
void DemoScreenMovingActor::Start()
{
	//Set up the actor
	a = new Actor();
	a->SetSize(4.0f);
	a->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
	theWorld.Add(a);





	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t = new TextActor("Console", "This Actor gets moved around by the left thumbstick. Try it.");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	t2 = new TextActor("Console", "Press [B] to rotate him.");
	t2->SetPosition(0, -4);
	t2->SetAlignment(TXT_Center);
	t3 = new TextActor("Console", "(The camera is a movable Actor, too -- right thumbstick.)");
	t3->SetPosition(0, -8);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t);
	theWorld.Add(t2);
	theWorld.Add(t3);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenMovingActor.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(a);
	#pragma endregion
}
コード例 #18
0
ファイル: LevelScreen.cpp プロジェクト: d909b/GADEL-Snake
void LevelScreen::ReceiveMessage(Message* m)
{
    if(m->GetMessageName() == "FoodConsumed")
    {
        std::stringstream ss;
        
        m_highscoreCounter += m_snake->getPointMultiplicator();
        
        ss << std::setfill('0') << std::setw(4) << m_highscoreCounter;
        
        m_highscore->SetDisplayString(ss.str());
    }
    else if(m->GetMessageName() == "PowerupConsumed")
    {
        std::stringstream ss;
        m_highscoreCounter += m_snake->getPointMultiplicator();
        ss << std::setfill('0') << std::setw(4) << m_highscoreCounter;
        
        Powerup* powerup = static_cast<Powerup*>(m->GetSender());
        
        if(powerup != NULL)
        {
            m_popupText->SetColor(1.f, 1.f, 1.f);
            m_popupText->SetDisplayString(powerup->getDescription());
            m_popupText->ChangeColorTo(Color(1.0,0.0,0.0), 5.0, true, "HidePopup");
            theWorld.Add(m_popupText, kUILayer);
        }
    }
    else if(m->GetMessageName() == "HidePopup")
    {
        theWorld.Remove(m_popupText);
    }
    else if(m->GetMessageName() == "EnterPressed")
    {
        theSwitchboard.UnsubscribeFrom(this, "EnterPressed");
        theSwitchboard.Broadcast(new Message("ShowMenu"));
    }
    else if(m->GetMessageName() == "ObstacleHit")
    {
        theWorld.Remove(m_popupText);
        m_snake->stop();
                
        TextActor* gameOver = new TextActor("popup", "GAME OVER");
        gameOver->SetPosition(-4.8f, 4.0f);
        gameOver->SetColor(1.f, 1.f, 1.f);
        
        TextActor* hitEnterText = new TextActor("standard", "Hit [Enter] to get back to menu...");
        hitEnterText->SetPosition(-8.8f, 0.0f);
        hitEnterText->SetColor(1.f, 1.f, 1.f);
        
        addRenderable(gameOver, kUILayer);
        addRenderable(hitEnterText, kUILayer);
        
        theSwitchboard.SubscribeTo(this, "EnterPressed");
    }
}
コード例 #19
0
void DemoScreenDefFile::Start()
{

	//CreateActor loads up an Actor Definition file and makes the actor from it
	a = Actor::Create("simple_actor"); //string is the file to load from -- 
									   // must be located in Config/ActorDef and end with ".lua"
	
	//You still need to add it to the world after it's been created
	theWorld.Add(a);
	
	





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	t = new TextActor("Console", "This Actor was placed using an archetype from an actor definition file.");
	t->SetPosition(0, 4.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	t2 = new TextActor("Console", "You can be data-driven if you want to!");
	t2->SetPosition(0, 3.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenDefFile.cpp, demo_actors.lua");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(a);
	#pragma endregion
}
コード例 #20
0
void DemoScreenSimpleActor::Start()
{
	//Creating a new, generic actor is simple. 
	a = new Actor();
	
	//Sizes and coordinates are always in GL units, which can mean whatever you decide they mean
	// -- our physics packages (Box2D) assumes that they mean meters, though. 
	a->SetSize(5.0f); 
	
	//R, G, B, [A]
	a->SetColor(0,0,0);

	//We have to add it to the world for it to be drawn. All Actors implement Update and Render
	// methods that get called once per frame. All your logic should happen in the Update function,
	// and you should only implement Render if you have to do something out of the ordinary. 
	theWorld.Add(a);





	//Demo housekeeping below this point. 
	#pragma region Demo Housekeeping
	t = new TextActor("Console", "Here's a simple Actor. (Press [B] to change it.)");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenSimpleActor.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(a);
	#pragma endregion
}
コード例 #21
0
void DemoScreenPathfinding::Start()
{
	//Set up our obstacle course
	theWorld.LoadLevel("maze");
	
	//Create the bounding box that will limit the pathfinding search area
	BoundingBox bounds(Vector2(-20, -20), Vector2(20, 20));
	
	//Create our pathfinding graph. In our 2D worlds, this is a relatively fast
	// operation -- you shouldn't be doing it every frame, but recalculating every
	// so often if your world has changed is not inappropriate. 
	theSpatialGraph.CreateGraph(
		0.75f, //The size of the entity you want to pathfind (so the generator
		       //  can know how small a space can be and still have it fit.)
		bounds //The search area
	);
	
	//Create a MazeFinder (class definition below), and put him in the bottom
	//  left corner of the maze
	MazeFinder *mf = new MazeFinder();
	mf->SetPosition(-11.5, -8);
	theWorld.Add(mf);
	
	//Send him to the upper right, watch him scurry
	mf->GoTo(Vector2(11.5, 8));
	
	
	
	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	String description = "This little dude is pathfinding through the area.";
	description += "\n\nClick the mouse to give him a new target.";
	description += "\n\nPress [B] to see the pathfinding graph.";
	TextActor *t = new TextActor("Console", description);
	t->SetAlignment(TXT_Center);
	t->SetPosition(0.0f, -5.0f);
	theWorld.Add(t);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenPathfinding.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(mf);
	ActorSet walls = theTagList.GetObjectsTagged("maze_wall");
	ActorSet::iterator it = walls.begin();
	while (it != walls.end())
	{
		_objects.push_back(*it);
		it++;
	}
	#pragma endregion
}
コード例 #22
0
void DemoScreenInstructions::Start()
{
	//Just some text actors to give instructions. Nothing much to see here. 
	TextActor *t = new TextActor("Console", "This demo is designed to be super simple. Maybe too much so.");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	TextActor *t2 = new TextActor("Console", "Each example is self-contained within the file shown at the bottom left.");
	t2->SetPosition(0, 2);
	t2->SetAlignment(TXT_Center);
	TextActor *t3 = new TextActor("Console", "The files are pretty thoroughly commented, so check them out to see how we do things.");
	t3->SetPosition(0, 0.5);
	t3->SetAlignment(TXT_Center);
	TextActor *t4 = new TextActor("Console", "Press [A] on the 360 Controller to go to the next example, and Back to go back.");
	t4->SetPosition(0, -3.5);
	t4->SetAlignment(TXT_Center);

	theWorld.Add(t);
	theWorld.Add(t2);
	theWorld.Add(t3);
	theWorld.Add(t4);





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenInstructions.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(t4);
	#pragma endregion
}
コード例 #23
0
void DemoScreenStart::Start()
{
	//TextActors, oddly enough, let you display text!
	TextActor *t = new TextActor("Console", "Welcome to Angel. This is a quick demo of what we can do.");
	t->SetPosition(0, 3.5);
	t->SetAlignment(TXT_Center);
	TextActor *t2 = new TextActor("Console", "(press [A] on the 360 controller or space bar to continue)");
	t2->SetPosition(0, 2);
	t2->SetAlignment(TXT_Center);

	theWorld.Add(t);
	theWorld.Add(t2);

	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenStart.cpp");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	#pragma endregion
}
コード例 #24
0
void DemoScreenLevelFile::Start()
{
	//Loads the file from Config\ActorDef\level_demo.lua
	// Level files automatically add their actors to the world. 
	theWorld.LoadLevel("level_demo");

	//Since the Actors were just added directly to the world,
	//  we don't have handles to them. The level definition
	//  gave them the tag "spawned," so we can get them that way.
	ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
	ActorSet::iterator it = spawnedActors.begin();
	while (it != spawnedActors.end())
	{
		//Can check Individual actors for tags as well.
		if ((*it)->IsTagged("left-tilted")) 
		{
			(*it)->SetRotation(25.0f);
		}
		else if ((*it)->IsTagged("right-tilted"))
		{
			(*it)->SetRotation(-25.0f);
		}
		//Applying tags
		(*it)->Tag("rotated");

		//Removing tags
		(*it)->Untag("spawned");
		it++;
	}





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	t = new TextActor("Console", "These Actors were placed and tagged (\"left-tilted\"");
	t->SetPosition(0, 5.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t);
	t2 = new TextActor("Console", "and \"right-tilted\") using a level definition file.");
	t2->SetPosition(0, 4.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2);
	t3 = new TextActor("Console", "Then their rotations were set based on those tags.");
	t3->SetPosition(0, -4.5);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t3);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLevelFile.cpp, level_demo.lua");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc);
	_objects.push_back(fileLoc);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	it = spawnedActors.begin();
	while (it != spawnedActors.end())
	{
		_objects.push_back(*it);
		it++;
	}
	#pragma endregion
}
コード例 #25
0
// save map actors into memory
void MapInfoXmlWriter::SaveActors(const std::string &Filename, std::map<long, Actor *> * vec)
{
	TiXmlDocument doc;
 	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
	doc.LinkEndChild( decl );

	TiXmlElement * root = new TiXmlElement("actors");
	doc.LinkEndChild( root );

	std::map<long, Actor *>::const_iterator it = vec->begin();
	std::map<long, Actor *>::const_iterator end = vec->end();
	for(; it != end; ++it)
	{
		TiXmlElement * act = new TiXmlElement( "actor" );
		root->LinkEndChild(act);
		act->SetAttribute("id", it->second->GetId());
		act->SetAttribute("type", it->second->GetType());
		act->SetDoubleAttribute("posX", it->second->GetPosX());
		act->SetDoubleAttribute("posY", it->second->GetPosY());
		act->SetDoubleAttribute("posZ", it->second->GetPosZ());
		act->SetDoubleAttribute("sizeX", it->second->GetSizeX());
		act->SetDoubleAttribute("sizeY", it->second->GetSizeY());
		act->SetDoubleAttribute("sizeZ", it->second->GetSizeZ());
		act->SetDoubleAttribute("offsetsizeY", it->second->GetOffsetSizeY());
		act->SetDoubleAttribute("rotation", it->second->GetRotation());
		act->SetAttribute("passable", it->second->IsPassable());
		act->SetAttribute("depthmask", it->second->IsDepthMask());
		act->SetAttribute("movable", it->second->IsMovable());
		act->SetAttribute("outputsignal", it->second->GetSignal());
		act->SetAttribute("attachedsound", it->second->GetAttachedSound());
		act->SetAttribute("collidable", it->second->GetCollidable());
		act->SetAttribute("actif", it->second->GetActif());
		act->SetAttribute("allowfreemove", it->second->GetAllowFreeMove());

		{
			std::vector<long> vect = it->second->GetTargets();
			std::stringstream str;
			if(vect.size() > 0)
				str<<vect[0];

			for(size_t i=1; i<vect.size(); ++i)
				str<<","<<vect[i];

			act->SetAttribute("signaltargets", str.str());
		}

		if(it->second->GetRenderer() != NULL)
		{
			act->SetAttribute("renderertype", it->second->GetRendererType());

			std::vector<long> vect = it->second->GetRendererTarget();
			std::stringstream str;
			if(vect.size() > 0)
				str<<vect[0];

			for(size_t i=1; i<vect.size(); ++i)
				str<<","<<vect[i];
			act->SetAttribute("renderertarget", str.str());
		}


		switch(it->second->GetType())
		{
			case 1:	//text actor class
			{
				{
					TextActor * tmpa = static_cast<TextActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetAttribute("textid", tmpa->GetTextId());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;

			case 2:	//ladder actor class
			{
				{
					LadderActor * tmpa = static_cast<LadderActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetDoubleAttribute("deltaX", tmpa->GetDX());
					act->SetDoubleAttribute("deltaY", tmpa->GetDY());
					act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
					act->SetAttribute("direction", tmpa->GetDir());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;

			case 3:	//exit actor class
			{
				{
					ExitActor * tmpa = static_cast<ExitActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetDoubleAttribute("deltaX", tmpa->GetDX());
					act->SetDoubleAttribute("deltaY", tmpa->GetDY());
					act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
					act->SetAttribute("direction", tmpa->GetDir());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;

			case 4:	//door actor class
			{
				{
					DoorActor * tmpa = static_cast<DoorActor *>(it->second);
					act->SetDoubleAttribute("zoneSizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zoneSizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zoneSizeZ", tmpa->GetZoneZ());
					act->SetAttribute("locked", tmpa->GetLocked());
					act->SetAttribute("keyid", tmpa->GetKeyId());
					act->SetAttribute("hide", tmpa->GetHide());
					act->SetAttribute("destroykey", tmpa->GetDesKey());

					act->SetDoubleAttribute("OpenTransX", tmpa->GetOpenTransX());
					act->SetDoubleAttribute("OpenTransY", tmpa->GetOpenTransY());
					act->SetDoubleAttribute("OpenTransZ", tmpa->GetOpenTransZ());
					act->SetDoubleAttribute("OpenTransSpeedX", tmpa->GetOpenTransSpeedX());
					act->SetDoubleAttribute("OpenTransSpeedY", tmpa->GetOpenTransSpeedY());
					act->SetDoubleAttribute("OpenTransSpeedZ", tmpa->GetOpenTransSpeedZ());
				}
			}
			break;

			case 5:	//container actor class
			{
				{
					ContainerActor * tmpa = static_cast<ContainerActor *>(it->second);
					act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
					act->SetAttribute("activationtype", tmpa->GetActivationType());

					const std::vector<ItemGroup> & lootlist = tmpa->GetLootList();
					for(size_t cci=0; cci<lootlist.size(); ++cci)
					{
						TiXmlElement * grit = new TiXmlElement( "itemgroup" );
						grit->SetDoubleAttribute("respawnTimeInMs", lootlist[cci].RespawningTime);
						act->LinkEndChild(grit);

						for(size_t ccj=0; ccj<lootlist[cci].groupelements.size(); ++ccj)
						{
							TiXmlElement * grelem = new TiXmlElement( "item" );
							grelem->SetDoubleAttribute("id", lootlist[cci].groupelements[ccj].id);
							grelem->SetDoubleAttribute("number", lootlist[cci].groupelements[ccj].number);
							grelem->SetDoubleAttribute("probability", lootlist[cci].groupelements[ccj].probability);
							grit->LinkEndChild(grelem);
						}
					}
				}
			}
			break;

			case 6:	//up exit actor class
			{
				{
					UpExitActor * tmpa = static_cast<UpExitActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetAttribute("direction", tmpa->GetDir());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;

			case 7:	//switch actor class
			{
				{
					SwitchActor * tmpa = static_cast<SwitchActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;

			case 8:	//area switch actor class
			{
				{
					AreaSwitch * tmpa = static_cast<AreaSwitch *>(it->second);
					act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
					act->SetAttribute("QuestToTriggerEnd", tmpa->GetQuestToTriggerEnd());
				}
			}
			break;

			case 9:	//floor switch actor class
			{
				{
					FloorSwitch * tmpa = static_cast<FloorSwitch *>(it->second);
					act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;


			case 10:	//lift actor class
			{
				{
					ScriptableActor * tmpa = static_cast<ScriptableActor *>(it->second);
					act->SetAttribute("autoattach", tmpa->GetAutoAttach());		
					
					const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
					if(scriptsV.size() > 0)
					{
						TiXmlElement * scripts = new TiXmlElement( "scripts" );
						act->LinkEndChild(scripts);

						for(size_t cci=0; cci<scriptsV.size(); ++cci)
						{
							TiXmlElement * script = new TiXmlElement( "script" );
							scripts->LinkEndChild(script);

							script->SetAttribute("type", scriptsV[cci].Type);
							script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
							script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
							script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
							script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
							script->SetAttribute("Sound", scriptsV[cci].Sound);
							script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
							script->SetAttribute("Animation", scriptsV[cci].Animation);
							script->SetAttribute("Flag", scriptsV[cci].Flag);
						}
					}
				}
			}
			break;

			case 11:	//hurt area class
			{
				{
					HurtArea * tmpa = static_cast<HurtArea *>(it->second);
					act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
					act->SetDoubleAttribute("lifetaken", tmpa->GetLifeTaken());
				}
			}
			break;


			case 12:	//NPC actor class
			{
				{
					NPCActor * tmpa = static_cast<NPCActor *>(it->second);
					act->SetAttribute("NPCType", tmpa->GetNPCType());
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetAttribute("Name", tmpa->GetName());
					
					const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
					if(scriptsV.size() > 0)
					{
						TiXmlElement * scripts = new TiXmlElement( "scripts" );
						act->LinkEndChild(scripts);

						for(size_t cci=0; cci<scriptsV.size(); ++cci)
						{
							TiXmlElement * script = new TiXmlElement( "script" );
							scripts->LinkEndChild(script);

							script->SetAttribute("type", scriptsV[cci].Type);
							script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
							script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
							script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
							script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
							script->SetAttribute("Sound", scriptsV[cci].Sound);
							script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
							script->SetAttribute("Animation", scriptsV[cci].Animation);
							script->SetAttribute("Flag", scriptsV[cci].Flag);
						}
					}
				}
			}
			break;


			case 13:	//scripted zone actor
			{
				{
					ScriptedZoneActor * tmpa = static_cast<ScriptedZoneActor *>(it->second);
					act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
					act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
					act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
					act->SetAttribute("neededitem", tmpa->GetNeededItemId());
					act->SetAttribute("destroyitem", tmpa->GetDesItem());
					act->SetAttribute("abortedmessage", tmpa->GetAbortedMessage());

					TiXmlElement * scripts = new TiXmlElement( "scripts" );
					act->LinkEndChild(scripts);
					const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
					for(size_t cci=0; cci<scriptsV.size(); ++cci)
					{
						TiXmlElement * script = new TiXmlElement( "script" );
						scripts->LinkEndChild(script);

						script->SetAttribute("type", scriptsV[cci].Type);
						script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
						script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
						script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
						script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
						script->SetAttribute("Sound", scriptsV[cci].Sound);
						script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
						script->SetAttribute("Animation", scriptsV[cci].Animation);
						script->SetAttribute("Flag", scriptsV[cci].Flag);

						script->SetAttribute("newMap", scriptsV[cci].NewMap);
						script->SetAttribute("spawning", scriptsV[cci].Spawning);
					}
				}
			}
			break;

			case 14:	//mailbox class
			{
				{
					MailboxActor * tmpa = static_cast<MailboxActor *>(it->second);
					act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
					act->SetAttribute("activationtype", tmpa->GetActivationType());
				}
			}
			break;
		}
	}


	doc.SaveFile(Filename);
}