Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualAlejandro

Posted 20 February 2013 - 10:32 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


#1Alejandro

Posted 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();
		}
	}
}

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