示例#1
0
def draw(c, idx, directory):
    # print(c,directory)
    pygame.init()
    font_t = ftfont.Font("fonts/NotoSansCJKtc-Regular.otf", 32)
    font_s = ftfont.Font("fonts/NotoSansCJKsc-Regular.otf", 32)
    rtext = font_t.render(c, True, (0, 0, 0), (255, 255, 255))
    if rtext is None:
        rtext = font_s.render(c, True, (0, 0, 0), (255, 255, 255))

    rtext = pygame.transform.scale(rtext, (32, 32))

    pygame.image.save(rtext, directory + str(idx) + ".jpg")
    return True
示例#2
0
def draw(c, idx, directory, lang):
    pygame.init()
    #font = pygame.font.Font("./fonts/NotoSansCJKsc-Black.otf", 36)
    if lang == 'zh_traditional':
        font = ftfont.Font("./fonts/NotoSansCJKtc-Regular.otf", 36)
    elif lang == 'zh_simplified':
        font = ftfont.Font("./fonts/NotoSansCJKsc-Regular.otf", 36)
    elif lang == 'ja':
        font = ftfont.Font("./fonts/NotoSansCJKjp-Regular.otf", 36)
    elif lang == 'ko':
        font = ftfont.Font("./fonts/NotoSansCJKkr-Regular.otf", 36)
    rtext = font.render(c, True, (0, 0, 0), (255, 255, 255))
    rtext = pygame.transform.scale(rtext, (36, 36))
    pygame.image.save(rtext, directory + str(idx) + ".jpg")
示例#3
0
 def __init__(self, controller):
     try:
         open(self.REGULAR_FONT).close()
     except FileNotFoundError:
         fix_path()
     self._font = ftfont.Font(self.REGULAR_FONT, 50)
     self._small_font = ftfont.Font(self.REGULAR_FONT, 30)
     self._bold_font = ftfont.Font(self.BOLD_FONT, 30)
     self.__controller = controller
     try:
         self.__last_scene = controller.get_scene()
     except AttributeError:
         self.__last_scene = None
     self.game_objects = LayeredUpdates()
     self.screen_rect = pygame.display.get_surface().get_rect()
     background = pygame.Surface(self.screen_rect.size)
     background.fill((240, 240, 240))
     self.background = GameObject(self.game_objects,
                                  pygame.Rect(0, 0, 0, 0), background)
     self.game_objects.add(self.background)
示例#4
0
    def __init__(self, pos, size, text):
        super().__init__(pos, size)

        aa = True
        fg = TEAL
        bg = BLACK

        ftfont.init(
        )  # perhaps not spectacular to init the font system here but should be safe to do again and again
        abel = ftfont.Font('fonts/abel/Abel-Regular.ttf',
                           int(self.rect.height * 0.75))
        self.surf = abel.render(text, aa, fg, bg)
示例#5
0
    def __init__(self, controller):
        super().__init__(controller)
        self.__font = ftfont.Font(self.REGULAR_FONT, 50)
        self.text = self.__font.render("py-Man", True, (255, 255, 255))
        self.text = pad(self.text, (0, 100), (255, 100, 100))
        demo2 = Demo(self.game_objects, self.text.get_rect(), self.text)
        demo = GameObject(self.game_objects, pygame.Rect(100, 100, 30, 30))
        demo.image.fill((255, 100, 100))
        demo.add_component(Physics)
        demo.add_component(Sprite)
        demo.add_component(Player)
        background = pygame.Surface(self.screen_rect.size)
        background.fill((20, 20, 20))
        background = GameObject(self.game_objects, pygame.Rect(0, 0, 0, 0),
                                background)
        background.blit(demo)
        crect1 = Rect(self.screen_rect)
        crect1.right = crect1.left
        crect2 = Rect(self.screen_rect)
        crect2.bottom = crect2.top
        crect3 = Rect(self.screen_rect)
        crect3.left = crect3.right
        crect4 = Rect(self.screen_rect)
        crect4.top = crect4.bottom
        collider1 = Demo(self.game_objects, crect1)
        collider2 = Demo(self.game_objects, crect2)
        collider3 = Demo(self.game_objects, crect3)
        collider4 = Demo(self.game_objects, crect4)
        collider1.get_component(Physics).set_static(True)
        collider2.get_component(Physics).set_static(True)
        collider3.get_component(Physics).set_static(True)
        collider4.get_component(Physics).set_static(True)

        self.game_objects.add(background, demo2, demo, collider1, collider2,
                              collider3, collider4)
        my_event = pygame.event.Event(USEREVENT, code='wow')
        timers.set_timer(my_event, 1000, 5000)
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame
from pygame import ftfont
from math import sqrt, sin, cos, radians
import json
from sys import stdin
from copy import deepcopy

WIDTH, HEIGHT = (1000, 1000)
WHITE = (255, 255, 255)

pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))

ftfont.init()
abel = ftfont.Font('christmas/fonts/abel/Abel-Regular.ttf', 15)


def pentaRotate(vec):
    retVal = []
    for i in range(5):
        retVal.append(vec.rotate(360 / 5 * i))
    return retVal


def translateToPygameOrigin(vecList):
    origin = pygame.Vector2(WIDTH / 2, HEIGHT / 2)
    translated = []
    for coord in vecList:
        translated.append(coord + origin)
    return translated