# Concave
# Copyright (C) 2012 Daniel Malmqvist
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Minimap():
    def generateMinimap(self, map):
        self.map = map
        self.size = 2
        
        self.maxx = len(map[0])
        self.maxy = len(map)
        
        
        
        smallRect = pygame.Rect((0,0, self.maxx, self.maxy))
        self.minimapSmall = pygame.Surface(smallRect.size, pygame.SRCALPHA)
        
        for x in range(0, self.maxx):
            for y in range(0, self.maxy):
                if self.map[y][x] == 0 or self.map[y][x] == 2:
                    self.minimapSmall.set_at((x, y), (250,100,0))
                elif self.map[y][x] == 1:
                    self.minimapSmall.set_at((x, y), (250,255,255))
                
        
        self.minimapBig = pygame.transform.scale2x(self.minimapSmall)
        self.minimapSmall = pygame.transform.scale2x(self.minimapBig)
        
        
    def getSmallImage(self, x, y):
        #x-=320
        #y-=240
        
        x /= 8
        y /= 8
        
        rect = pygame.Rect((x - 48, y - 48, 92, 92))
        image = pygame.Surface(rect.size, pygame.SRCALPHA)

        image.blit(self.minimapSmall, (0, 0), rect)
        image.set_colorkey(-1, RLEACCEL)
        return image

    def getBigImage(self, x, y):
        pass