Esempio n. 1
0
    def __init__(self, world, windowRes, viewportRes):
        self.world = world

        self.backgroundColor = hex2rgb("0E0E0E")
        self.window = pygame.display.set_mode(windowRes)
        
        self.viewportRes = viewportRes
        # viewportRes has to be square & odd for viewportCenter to be correct
        self.viewportCenter = (viewportRes[0] // 2, viewportRes[1] // 2)
        self.viewportTiles = [None] * (viewportRes[0] * viewportRes[1])
        
        self.DRAWMODE_NORMAL = 0
        self.DRAWMODE_ELEVATION = 1
        self.DRAWMODE_BIOMES = 2
        self.currentDrawMode = self.DRAWMODE_NORMAL
        
        self.sprites = {}
        self.fontFace = "monospace"
        self.fontSize = windowRes[0] / self.viewportRes[0]
        self.font = pygame.font.SysFont(self.fontFace, self.fontSize)
        self.fontMini = pygame.font.SysFont(self.fontFace, self.fontSize/2)
        self.fontDimensions = self.font.size("@")
        
        self.cursor = (0, 0)
        self.cursorSurface = pygame.Surface((self.fontSize, self.fontSize), pygame.SRCALPHA, 32)
        self.cursorSurface.fill(hex2rgba("F2F2F2", 50))
        
        self.descriptionFont = pygame.font.SysFont("monospace", 15)
Esempio n. 2
0
 def drawText(self):
     # initialize font; must be called after 'pygame.init()' to avoid 'Font not Initialized' error
     # render text
     for i, description in enumerate(self.world.descriptions):
         label = self.descriptionFont.render(description[0], False, hex2rgb(description[1]))
         # Magic numbers here, but no need to fix this until we decide to
         # change the scalars in self.getFontRect()
         self.window.blit(label, (10, 350 + 20 * i))
Esempio n. 3
0
    def __init__(self, name, description, glyphs, color, adjacentTiles=None, collidable=False):
        self.name = name
        self.description = description
        self.adjacentTiles = adjacentTiles
        
        self.glyph = random.choice(glyphs)
        self.allGlyphs = glyphs
        self.color = hex2rgb(color)
        
        self.collidable = collidable
        self.elevation = -1
        self.biomeID = -1

        self._hsvComponents = {"hue": 0, "saturation": 1, "brightness": 2}