import pygame
pygame.init()

from game.classes.Tile import Tile

class Game_Area( pygame.sprite.Sprite ):
	def __init__( self, width, height, tile_size, tile_color, tile_color2, bg_color ):
		pygame.sprite.Sprite.__init__( self )

		self.image = pygame.Surface( ( width, height ) )
		self.rect = self.image.get_rect( topleft = ( 0, 0 ) )
		self.image.fill( bg_color )

		self._width = width
		self._height = height
		self._tile_size = tile_size
		self._color = tile_color
		self._color2 = tile_color2

		self._tiles = pygame.sprite.Group()

		self._rows = self._width // self._tile_size
		self._cols = self._height // self._tile_size

		top = 0
		left = 0

		counter = 0

		for row in range( self._rows ):
			for col in range( self._cols ):

				if counter % 2 == 0 or counter == 0:
					clr = self._color
				else:
					clr = self._color2
				
				self._tiles.add( Tile( top, left, self._tile_size, clr ) )

				left += self._tile_size
				counter += 1

			left = 0
			counter += 1
			top += self._tile_size

		self.draw_tiles()

	def draw_tiles( self ):
		"""
		Internal.
		"""

		self._tiles.draw( self.image )


	def update( self ):
		pass
		#self.draw_tiles()
