From 9f12983cf23a6af0c47697416eb4e094327eb3b1 Mon Sep 17 00:00:00 2001 From: Timm Weber Date: Sat, 8 Aug 2015 05:18:04 +0200 Subject: added weight rendering and updated pygame.font to pygame.freetype --- test.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/test.py b/test.py index 303d6d6..e030e87 100644 --- a/test.py +++ b/test.py @@ -2,6 +2,7 @@ from agarnet.agarnet import client from agarnet.agarnet import utils import pygame from pygame import gfxdraw +from pygame import freetype from pygame.locals import * import sys import math @@ -129,25 +130,29 @@ def drawCell(cell): gfxdraw.aacircle(screen, cx, cy, int(radius/2.5), (255,255,255)) gfxdraw.circle(screen, cx, cy, int(radius/2.5), (255,255,255)) - font_size = 20 - pygame.font.init() - font = pygame.font.SysFont(pygame.font.get_default_font(), font_size) - surface = font.render(cell.name, 1, (0, 0, 0)) - screen.blit(surface, (cx - (surface.get_width()/2), cy + radius)) + font_size = 16 + pygame.freetype.init() + font = pygame.freetype.SysFont(pygame.freetype.get_default_font(), font_size) + + surface = font.render(cell.name, (0, 0, 0)) + screen.blit(surface[0], (cx - (surface[0].get_width()/2), cy + radius + 5)) + + surface = font.render(str(int(cell.mass)), (255, 255, 255)) + screen.blit(surface[0], (cx - (surface[0].get_width()/2), cy - (surface[0].get_height()/2))) def draw_leaderboard(): def filter(item): return item[1] leaderboard = list(map(filter, c.world.leaderboard_names)) - font_size = 20 - pygame.font.init() - font = pygame.font.SysFont(pygame.font.get_default_font(), font_size) - next_y = 0 + font_size = 16 + pygame.freetype.init() + font = pygame.freetype.SysFont(pygame.freetype.get_default_font(), font_size) + next_y = 5 for i, s in zip(range(1, len(leaderboard)+1), leaderboard): - surface = font.render((str(i) + ": " +s), 1, (0, 0, 0)) - screen.blit(surface, (0, next_y)) - next_y += surface.get_height() + surface = font.render((str(i) + ": " +s), (0, 0, 0)) + screen.blit(surface[0], (5, next_y)) + next_y += surface[0].get_height()+5 sub = MeinSubskribierer() c = client.Client(sub) -- cgit v1.2.3