Jump to content

  • Log In with Google      Sign In   
  • Create Account


Alejandro

Member Since 30 Jan 2011
Offline Last Active Nov 28 2013 08:49 PM

#5068484 Looking for an AI book about crowd behaviour

Posted by Alejandro on 09 June 2013 - 02:52 PM

Movement behaviour is a common topic on any AI for games  book, you can check this oune out: http://books.google.com.mx/books/about/Artificial_intelligence_for_games.html?id=1OJ8EhvuPXAC&redir_esc=y




#5034607 Game Architecture/Design Pattern?

Posted by Alejandro on 20 February 2013 - 10:29 AM

Hello,

 

I want to know if there are any game architectures that are recommended, well, actually I don't know if I can call them architectures or design patterns.

 

Basically what I want to know is how do you structure your games at a logical for example I tend to the following.

 

I create an object named GameMaster, this object controls the game (enemies, ambient, etc) and knows the state of everything in the game, the control is done through Managers, for example EnemieManager, AmbientManager, etc. This managers don't communicate directly, the communication has to go throught the GameMaster.

 

In a more plactical way say we have the following:

 

class GameMaster
{
	Player player;
	EnemyManager enemyManager;
	GameStatus status;

	void update()
	{
		if(enemyManager.enemies == 0)
		{
			status = GameStatus.EndGame;
		}

		if(status == GameStatus.EndGame)
		{
			player.stopInteraction();
		}
	}

	void draw()
	{
		drawString(status);
	}
}

 

Sure, the managers can also have control of a few elements... what I see in some friends code is more like...

 

class Player
{
	GameStatus status;

	void update()
	{
		if(status == GameStatus.EndGame)
		{
			player.stopInteraction();
		}
	}
        
        void draw()
        {
                drawString(status);
        }
}

class EnemiesManager
{
	Player player;
	int enemies; 

	void update()
	{
		if(enemies == 0)
		{
			player.status = GameStatus.EndGame;
		}
	}
}

So my doubt are, what is better? what is worse? are there any architecture/patterns for structuring the objects in the videogames?.

 

I follow the GameMaster pattern because it's easier to me to structure things like this, but maybe this is not the best pattern...

 

 

Any literature on the topic is appreaciated wub.png




PARTNERS