示例#1
0
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");
    }
}
示例#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
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
}
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
}
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
}
示例#6
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
}
示例#7
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
}
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
}
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
}
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
}
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
}
示例#12
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);
   }
示例#13
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
}
示例#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 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
}
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
}
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
}
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
}
示例#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
}
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
}