Example #1
0
	def render(self, dt):
		self.window.clear()
		
		self.set_projection()
		
		font.add_file('./font/Pure-ThinDuranGo.ttf')
		arial = font.load('Roman', 9, dpi=96)
		
		text = 'Hello, world!'
		glyphs = arial.get_glyphs(text)

		#gs = GlyphString(text, glyphs)
		# glyph_string.draw()
		#for g in gs:
		#	g.blit(x, y, z=0, width=None, height=None)


		label = pyglet.text.Label('Hello, world a',
			#font_name='./font/Pure-ThinDuranGo.ttf',
			font_size=14,
			x=10, y=10
		)
		label.draw()

		#glBegin(GL_LINES)
		#for ob in self.model:
		#	self.render_ob(*ob)
		#glEnd()

		self.window.flip()
Example #2
0
    def __init__(self, space, run_pyglet, load):

        space.gravity = (G_VECTOR[0], G_VECTOR[1])
        self.space = space
        self.epoch = 0

        if (run_pyglet):
            pyglet.window.Window.__init__(self,
                                          width=constants.W_WIDTH,
                                          height=constants.W_HEIGHT)
            self.wind = 0

        self.run_pyglet = run_pyglet

        self.push_handlers(GameEventHandler(self))
        self.batch_draw = pyglet.graphics.Batch()
        font.add_file('./resources/neon_pixel.ttf')
        neon_pixel = font.load('Neon Pixel-7')
        self.define_scenario()

        self.define_game_objects()

        signal.signal(signal.SIGINT, signal_handler)

        self.pole_angle = self.get_pole_angle()
        self.angular_velocity = 0
        self.learner = AI_controller.Learner(self, load)

        pyglet.clock.schedule(self.update)
        if not (run_pyglet):
            filename = datetime.datetime.fromtimestamp(
                time.time()).strftime('%Y%m%d%H%M%S')
            print "Gerando arquivo para listagem das performances (%s.txt)" % filename
            self.performances_file = open(("./performance/%s.txt" % filename),
                                          "w+")
Example #3
0
 def __init__(self, *args, **kwargs):
   super(MainWindow, self).__init__(*args, **kwargs)
   self.keys = window.key.KeyStateHandler()
   self.push_handlers(self.keys)
   # self.set_exclusive_mouse()
   self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
   self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
   self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
   self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
   self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
   self.instbkwidth, self.instbkheight = 480, 400
   bmplen = (self.instbkwidth / 8) * self.instbkheight
   self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
   self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
   self.printing, self.solver = 1, deque()
   self.stat = [None, 0, Queue.Queue(512)] # (key(1-9), direc), count, queue
   self.cmax, self.tanim = 18, [6, 3, 1, 3] # frames in rotate moving, speeds
   self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
   for i in xrange(1, self.cmax):
     t = i * math.pi / (2.0 * self.cmax) # 0 < t < pi/2
     self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
   self.tcos[self.cmax], self.tsin[self.cmax] = 0.0, 1.0 # pi/2 regulation
   self.InitRot()
   self.InitAxis()
   self.InitGL(self.width, self.height)
   self.textures = [None] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
   self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
   font.add_file(FONT_FILE)
   self.font = font.load(FONT_FACE, 20)
   self.fontcolor = (0.5, 0.8, 0.5, 0.9)
   self.fps_display = clock.ClockDisplay(font=self.font, color=self.fontcolor)
   self.fps_pos = (-60.0, 30.0, -60.0)
   clock.set_fps_limit(60)
   clock.schedule_interval(self.update, 1.0 / 60.0)
Example #4
0
    def __init__(self, loader):
        from pyglet import font as PyFont
        from threading import Thread
        self.__loader = loader
        self.__loader.fontManager = self

        self.__lastScaleX = 1
        self.__lastScaleY = 1

        self.__chars = {}
        lastChar = None

        f = open("config/letters.txt")
        txt = f.readlines()
        f.close()

        for line in txt:
            line = line.replace("\n", "").replace("\r", "")
            if line != "":
                if len(line) == 1:
                    lastChar = line[0]
                    self.__chars[lastChar] = []
                else:
                    self.__chars[lastChar].append(line)

        PyFont.add_file('others/font/HammerFat.ttf')
        self.__normalSize = 22
        self.__sizing()
        sizes = Thread(target=self.autoSizes)
        sizes.start()
Example #5
0
    def render(self):
        font.add_file(os.path.join(base_path, 'action_man.ttf'))

        # Hard-code 16-pt at 100 DPI, and hard-code the pixel coordinates
        # we see that font at when DPI-specified rendering is correct.
        fnt = font.load('Action Man', 16, dpi=120)

        self.text = font.Text(fnt, 'The DPI is 120', 10, 10)
Example #6
0
    def render(self):
        font.add_file(os.path.join(base_path, 'action_man.ttf'))

        # Hard-code 16-pt at 100 DPI, and hard-code the pixel coordinates
        # we see that font at when DPI-specified rendering is correct.
        fnt = font.load('Action Man', 16, dpi=120)

        self.text = font.Text(fnt, 'The DPI is 120', 10, 10)
    def render(self):
        font.add_file(os.path.join(base_path, 'courR12-ISO8859-1.pcf'))

        fnt = font.load('Courier', 16)

        h = fnt.ascent - fnt.descent + 10
        self.texts = [
            font.Text(fnt, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 10, h * 1),
        ]
Example #8
0
File: utils.py Project: Knio/miru
def default_font(size=10, style='mono'):
    global _defaultLoaded
    from pyglet import font
    filename,face = _font_styles.get(style, _font_styles['mono'])
    if not _defaultLoaded:
        fontpath = filepath.FilePath(__file__).parent().child('data').child(filename)
        font.add_file(fontpath.path)
        _defaultLoaded = True
    return font.load(face, size)
Example #9
0
 def load_font(self):
     # load external font from file
     # font_names = ['WarPriest3DRegular-Koxe', 'WarPriestCondensed-2Z8X', 'WarPriestExpanded-wpY9']
     font_names = ['EvilEmpire-4BBVK']
     for font_name in font_names:
         p = TruetypeInfo(f'./resources/fonts/evil-empire/{font_name}.ttf')
         name = p.get_name("name")
         p.close()
         font.add_file(f'./resources/fonts/evil-empire/{font_name}.ttf')
         print("Loaded font " + name)
 def __init__(self, handler):
     mode.Renderer.__init__(self, handler)
     font.add_file('resources/amsterdam.ttf')
     self.amsterdam = font.load('Amsterdam Graffiti', 45)
     self.amsterdam_detail = font.load('Amsterdam Graffiti', 24)
     if(not self.handler.menu_boxes):
         self.handler.menu_boxes = []
         for i in range(10):
             self.handler.menu_boxes.append((50, 700, 
                 575 - i * BAR_HEIGHT, 575 - (i + 1) * BAR_HEIGHT))
    def render(self):
        font.add_file(os.path.join(base_path, 'courR12-ISO8859-1.pcf'))

        fnt = font.load('Courier', 16)

        h = fnt.ascent - fnt.descent + 10
        self.texts = [
            font.Text(fnt,
                      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
                      10, h * 1),
        ]
Example #12
0
    def __init__(self, space, run_pyglet, load, randomizer = None, mode = "single", player = 0):
        space.gravity = (G_VECTOR[0], G_VECTOR[1])
        self.space = space
        self.epoch = 0

        if(run_pyglet):
            pyglet.window.Window.__init__(self, width = constants.W_WIDTH, height = constants.W_HEIGHT)
            self.wind = 0

        self.run_pyglet = run_pyglet
        if randomizer == None:
            self.randomizer = Randomizer()
        else:
            self.randomizer = randomizer
        self.mode = mode
        self.opponent = None
        self.player   = player
        self.state    = "active"
        self.performances = []
        self.round    = 1

        self.push_handlers(GameEventHandler(self))
        self.batch_draw = pyglet.graphics.Batch()
        font.add_file('./resources/neon_pixel.ttf')
        neon_pixel = font.load('Neon Pixel-7')
        self.define_scenario()

        self.define_game_objects()
        signal.signal(signal.SIGINT, signal_handler)

        self.wind     = random.randint(-500, 500)
        self.friction = random.uniform(0.970, 0.999)


        self.pole_angle = self.get_pole_angle()
        self.angular_velocity = 0
        if self.mode == "single" or self.player == 1:
            self.learner = AI_controller.Learner(self, load)
        else:
            try:
                import Opponent
            except ImportError:
                print "Erro ao importar o pacote oponente"
                exit()
            self.learner = Opponent.Learner(self, load)
        self.current_iteration = 0

        if not(run_pyglet):
            filename =  datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d%H%M%S')
            print "Gerando arquivo para listagem das performances (%s.txt)" % filename
            self.performances_file = open(("./performance/%s.txt" % filename), "w+")

        pyglet.clock.schedule(self.update)
Example #13
0
def test_add_font(font_fixture, test_data, font_desc, font_file, font_options):
    """Test that a font distributed with the application can be displayed.

    Four lines of text should be displayed, each in a different variant
    (bold/italic/regular) of Action Man at 24pt.  The Action Man fonts are
    included in the test data directory (tests/data/fonts) as action_man*.ttf.
    """
    font.add_file(test_data.get_file('fonts', font_file))
    font_fixture.create_window()
    font_fixture.load_font(name='Action Man', **font_options)
    font_fixture.create_label()
    font_fixture.ask_question(
        """You should see {} style Action Man at 24pt.""".format(font_desc))
Example #14
0
def test_dpi(font_fixture, test_data, dpi, width, height):
    font.add_file(test_data.get_file('fonts', 'action_man.ttf'))
    question = (
        "The green vertical lines should match the left edge of the text" +
        "and the blue vertical lines should match the right edge of the text.")
    font_fixture.create_window()
    font_fixture.draw_custom_metrics = width, height
    font_fixture.load_font(
        name='Action Man',
        size=16,
        dpi=dpi,
    )
    font_fixture.create_label(text='The DPI is {}'.format(dpi), )
    font_fixture.ask_question(question, )
Example #15
0
def test_metrics_workaround(font_fixture, test_data):
    """Test workaround for font missing metrics.

    Font should fit between top and bottom lines.
    """
    font.add_file(test_data.get_file('fonts', 'courR12-ISO8859-1.pcf'))
    font_fixture.create_window(width=600, )
    font_fixture.draw_metrics = True
    font_fixture.load_font(
        name='Courier',
        size=16,
    )
    font_fixture.create_label(
        text='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', )
    font_fixture.ask_question(
        'The text should fit between the top and bottom lines', )
    def render(self):
        font.add_file(os.path.join(base_path, 'action_man.ttf'))

        fnt1 = font.load('Action Man', 16)
        fnt2 = font.load('Arial', 16)
        fnt3 = font.load('Times New Roman', 16)

        h = fnt3.ascent - fnt3.descent + 10
        self.texts = [
            font.Text(fnt1, 'Action Man', 10, h * 1),
            font.Text(fnt1, 'Action Man longer test with more words', 10, h*2),
            font.Text(fnt2, 'Arial', 10, h * 3),
            font.Text(fnt2, 'Arial longer test with more words', 10, h*4),
            font.Text(fnt3, 'Times New Roman', 10, h * 5),
            font.Text(fnt3, 'Times New Roman longer test with more words', 
                      10, h*6),
        ]
Example #17
0
    def render(self):
        font.add_file(os.path.join(base_path, 'action_man.ttf'))

        fnt1 = font.load('Action Man', 16)
        fnt2 = font.load('Arial', 16)
        fnt3 = font.load('Times New Roman', 16)

        h = fnt3.ascent - fnt3.descent + 10
        self.texts = [
            font.Text(fnt1, 'Action Man', 10, h * 1),
            font.Text(fnt1, 'Action Man longer test with more words', 10, h*2),
            font.Text(fnt2, 'Arial', 10, h * 3),
            font.Text(fnt2, 'Arial longer test with more words', 10, h*4),
            font.Text(fnt3, 'Times New Roman', 10, h * 5),
            font.Text(fnt3, 'Times New Roman longer test with more words', 
                      10, h*6),
        ]
Example #18
0
def display_hud():
    font.add_file('game/fonts/sprite_comic.ttf')

    global text_intro_menu
    text_intro_menu = pyglet.text.Label("Adventure Simulator Pilot",
                                        x=550,
                                        y=700)
    text_intro_menu.font_name = 'Sprite Comic'
    text_intro_menu.anchor_x = "center"
    text_intro_menu.anchor_y = "center"
    text_intro_menu.font_size = 40

    global text_intro_class_1
    text_intro_class_1 = pyglet.text.Label("Press Z to select the GLADIATOR",
                                           x=550,
                                           y=500)
    text_intro_class_1.font_name = 'Sprite Comic'
    text_intro_class_1.anchor_x = "center"
    text_intro_class_1.anchor_y = "center"
    text_intro_class_1.font_size = 30

    global text_intro_class_2
    text_intro_class_2 = pyglet.text.Label("Press X to select the RANGER",
                                           x=550,
                                           y=400)
    text_intro_class_2.font_name = 'Sprite Comic'
    text_intro_class_2.anchor_x = "center"
    text_intro_class_2.anchor_y = "center"
    text_intro_class_2.font_size = 30

    global text_intro_class_current
    text_intro_class_current = pyglet.text.Label("Current class: GLADIATOR",
                                                 x=550,
                                                 y=300)
    text_intro_class_current.font_name = 'Sprite Comic'
    text_intro_class_current.anchor_x = "center"
    text_intro_class_current.anchor_y = "center"
    text_intro_class_current.font_size = 30

    global text_intro_start

    text_intro_start = pyglet.text.Label("Press SPACE to start", x=550, y=100)
    text_intro_start.font_name = 'Sprite Comic'
    text_intro_start.anchor_x = "center"
    text_intro_start.anchor_y = "center"
    text_intro_start.font_size = 40
    def __init__(self, mainBatch, unit, value, valueType, critical):
        super().__init__()

        font.add_file('game/fonts/sprite_comic.ttf')
        if value < 1:
            value = 1

        self.value = value
        self.valueType = valueType
        self.unit = unit
        self.text = pyglet.text.Label(
            str(int(value)),
            x=self.unit.sprite.x + random.randint(0, self.unit.sprite.width),
            y=self.unit.sprite.y + random.randint(0, self.unit.sprite.height),
            batch=mainBatch,
            group=pyglet.graphics.OrderedGroup(3))
        self.text.font_name = 'Sprite Comic'
        self.text.font_size = 8
        self.opacity = 0
        self.red = 255
        self.green = 255
        self.blue = 255
        self.critical = critical

        if valueType == 0:
            self.red = 255
            self.green = 100
            self.blue = 100
            if critical == True:
                self.text.text = self.text.text + '!'
                self.text.font_size = 16
                self.green = 0
                self.blue = 0

        elif valueType == 1:
            self.red = 100
            self.green = 255
            self.blue = 100
            if critical == True:
                self.text.text = self.text.text + '!'
                self.text.font_size = 16
                self.red = 50
                self.blue = 50

        self.type = 30
Example #20
0
    def add_font(self, name):
        '''Add a font resource to the application.

        Fonts not installed on the system must be added to pyglet before they
        can be used with `font.load`.  Although the font is added with
        its filename using this function, it is loaded by specifying its
        family name.  For example::

            resource.add_font('action_man.ttf')
            action_man = font.load('Action Man')

        :Parameters:
            `name` : str
                Filename of the font resource to add.

        '''
        from pyglet import font
        file = self.file(name)
        font.add_file(file)
Example #21
0
def test_horizontal_metrics(font_fixture, test_data, font_name, text):
    """Test that the horizontal font metrics are calculated correctly.

    Some text in various fonts will be displayed.  Green vertical lines mark
    the left edge of the text.  Blue vertical lines mark the right edge of the
    text.
    """
    font.add_file(test_data.get_file('fonts', 'action_man.ttf'))
    question = (
        "The green vertical lines should match the left edge of the text" +
        "and the blue vertical lines should match the right edge of the text.")
    font_fixture.create_window(width=600, )
    font_fixture.draw_metrics = True
    font_fixture.load_font(
        name=font_name,
        size=16,
    )
    font_fixture.create_label(text=text, )
    font_fixture.ask_question(question, )
Example #22
0
    def add_font(self, name):
        '''Add a font resource to the application.

        Fonts not installed on the system must be added to pyglet before they
        can be used with `font.load`.  Although the font is added with
        its filename using this function, it is loaded by specifying its
        family name.  For example::

            resource.add_font('action_man.ttf')
            action_man = font.load('Action Man')

        :Parameters:
            `name` : str
                Filename of the font resource to add.

        '''
        from pyglet import font
        file = self.file(name)
        font.add_file(file)
Example #23
0
    def __init__(self, handle="classic.map", wanted_players=1, total_dots_eaten=0, xoff=0, yoff=0):
        '''
        This is... a really big class. It parses a grid from a game file, and takes care of drawing the grid, updating
        entities, etc.
        :param handle: The filename of the game to play
        :returns: Nothing
        '''

        self.xoff = xoff
        self.yoff = yoff

        self.players = []
        self.ghosts = []
        self.grid = []

        self.lives = 3
        self.level = 1
        self.score = 0
        self.over = False

        self.should_update = True

        self.wanted_players = wanted_players

        self.load_static_map(handle, self.xoff, self.yoff)
        self.governor = Governor(self, handle)

        self.total_dots_eaten = total_dots_eaten
        self.dots_eaten = self.pups_eaten = 0

        self.init_buffers()

        fontlib.add_file("resources/prstartk.ttf")

        self.score_label = pyglet.text.Label("foo",
                                             font_name='Press Start K',
                                             font_size=int(12 / GRID_DIM * 24),
                                             x=0, y=int(10 * GRID_DIM / 24))

        self.lives_label = pyglet.text.Label("foo",
                                             font_name='Press Start K',
                                             font_size=int(12 / GRID_DIM * 24),
                                             x=0, y=int(30 * GRID_DIM / 24))
Example #24
0
 def __init__(self):
     super(EffectLayer, self).__init__()
     effectDispatchCenter.push_handlers(self)
     font.add_file(Globals.FONT_FILE)
     self.assets = {
         "Default": Sprite(Globals.SPELL_DEFAULT),
         "Oops": Sprite(Globals.SPELL_DEFAULT),
         "NoSpell": Sprite(Globals.SPELL_NOSPELL),
         "Heal": Sprite(Globals.SPELL_DEFAULT),
         "GreaterHeal": Sprite(Globals.SPELL_DEFAULT),
         "Strike": Sprite(Globals.SPELL_DEFAULT),
         "OpenMind": Sprite(Globals.SPELL_DEFAULT),
         "Anguish": Sprite(Globals.SPELL_DEFAULT),
         "BloodArrow": Sprite(Globals.SPELL_DEFAULT),
         "Turmoil": Sprite(Globals.SPELL_DEFAULT),
         "Nova": Sprite(Globals.SPELL_DEFAULT),
         "Equilibrium": Sprite(Globals.SPELL_DEFAULT),
         "OmniPower": Sprite(Globals.SPELL_DEFAULT),
         "Eruption": Sprite(Globals.SPELL_DEFAULT),
         "Fade": Sprite(Globals.SPELL_DEFAULT),
         "CorruptedBlood": Sprite(Globals.SPELL_DEFAULT),
     }
     self.effects = {
         "Default": self._Default,
         "Oops": self._Oops,
         "NoSpell": self._NoSpell,
         "Heal": self._Heal,
         "GreaterHeal": self._Heal,
         "Strike": self._Strike,
         "OpenMind": self._Default,
         "Anguish": self._Default,
         "BloodArrow": self._Default,
         "Turmoil": self._Default,
         "Nova": self._Default,
         "Equilibrium": self._Default,
         "OmniPower": self._Default,
         "Eruption": self._Default,
         "Fade": self._Default,
     }
Example #25
0
 def __init__(self, *args, **kwargs):
     super(MainWindow, self).__init__(*args, **kwargs)
     self.keys = window.key.KeyStateHandler()
     self.push_handlers(self.keys)
     # self.set_exclusive_mouse()
     self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
     self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
     self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
     self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
     self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
     self.instbkwidth, self.instbkheight = 480, 400
     bmplen = (self.instbkwidth / 8) * self.instbkheight
     self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
     self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
     self.printing, self.solver = 1, deque()
     self.stat = [None, 0,
                  Queue.Queue(512)]  # (key(1-9), direc), count, queue
     self.cmax, self.tanim = 18, [6, 3, 1,
                                  3]  # frames in rotate moving, speeds
     self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
     for i in xrange(1, self.cmax):
         t = i * math.pi / (2.0 * self.cmax)  # 0 < t < pi/2
         self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
     self.tcos[self.cmax], self.tsin[
         self.cmax] = 0.0, 1.0  # pi/2 regulation
     self.InitRot()
     self.InitAxis()
     self.InitGL(self.width, self.height)
     self.textures = [None
                      ] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
     self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
     font.add_file(FONT_FILE)
     self.font = font.load(FONT_FACE, 20)
     self.fontcolor = (0.5, 0.8, 0.5, 0.9)
     self.fps_display = clock.ClockDisplay(font=self.font,
                                           color=self.fontcolor)
     self.fps_pos = (-60.0, 30.0, -60.0)
     clock.set_fps_limit(60)
     clock.schedule_interval(self.update, 1.0 / 60.0)
Example #26
0
    def render(self):
        font.add_file(os.path.join(base_path, "action_man.ttf"))
        font.add_file(os.path.join(base_path, "action_man_bold.ttf"))
        font.add_file(os.path.join(base_path, "action_man_italic.ttf"))
        font.add_file(os.path.join(base_path, "action_man_bold_italic.ttf"))

        fnt = font.load("Action Man", self.font_size)
        fnt_b = font.load("Action Man", self.font_size, bold=True)
        fnt_i = font.load("Action Man", self.font_size, italic=True)
        fnt_bi = font.load("Action Man", self.font_size, bold=True, italic=True)

        h = fnt.ascent - fnt.descent

        self.labels = [
            font.Text(fnt, "Action Man", 10, 10 + 3 * h),
            font.Text(fnt_i, "Action Man Italic", 10, 10 + 2 * h),
            font.Text(fnt_b, "Action Man Bold", 10, 10 + h),
            font.Text(fnt_bi, "Action Man Bold Italic", 10, 10),
        ]
Example #27
0
    def render(self):
        font.add_file(os.path.join(base_path, 'action_man.ttf'))
        font.add_file(os.path.join(base_path, 'action_man_bold.ttf'))
        font.add_file(os.path.join(base_path, 'action_man_italic.ttf'))
        font.add_file(os.path.join(base_path, 'action_man_bold_italic.ttf'))

        fnt = font.load('Action Man', self.font_size)
        fnt_b = font.load('Action Man', self.font_size, bold=True)
        fnt_i = font.load('Action Man', self.font_size, italic=True)
        fnt_bi = font.load('Action Man', self.font_size, bold=True, italic=True)

        h = fnt.ascent - fnt.descent

        self.labels = [
            font.Text(fnt, 'Action Man', 10, 10 + 3 * h),
            font.Text(fnt_i, 'Action Man Italic', 10, 10 + 2 * h),
            font.Text(fnt_b, 'Action Man Bold', 10, 10 + h),
            font.Text(fnt_bi, 'Action Man Bold Italic', 10, 10)
        ]
Example #28
0
import pyglet
from pyglet import font

font.add_file('res/fonts/peace_sans.otf')  #Peace Sans
font.add_file('res/fonts/Vodafone_Rg_Bold.ttf')  #Vodafone Rg
font.add_file('res/fonts/Nokia_Pure_Text_Bold.ttf')  #Vodafone Rg
font.add_file('res/fonts/PromtImperial_Bold.ttf')  #PromtImperial
font.add_file('res/fonts/Roboto_Bold.ttf')  #Roboto
Example #29
0
import pyglet.resource
from pyglet import font
from pkg_resources import resource_stream


class Loader(pyglet.resource.Loader):
    def file(self, name, mode='rb'):
        assert mode == 'rb', "Resource files are read-only."
        return resource_stream(__name__, name)


loader = Loader()
image = loader.image
texture = loader.texture
file = loader.file

font.add_file(resource_stream(__name__, 'data/fonts/atomic-clock-radio.ttf'))
Example #30
0
def main():
    # the entry point of the game
    # look at this if you want to understand
    # the game

    width = 1024
    height = 768
    win_size = (width, height)
    # bounds in wich objects may exist
    bounds = math.hypot(*win_size)/2 + 300
    
    # load font for displaying score
    # (necessary on windows)
    font.add_file('fonts/Starjout.ttf')
    
    # create a window; opengl context inclusive
    window = pyglet.window.Window(*win_size)

    # handlesthe displaying of images and text
    view = View()

    # create the world space
    world = World(win_size, bounds, view)

    # register models
    world.register_model(Asteroid)
    world.register_model(Bullet)
    world.register_model(Spaceship)

    # the player controls a spaceship
    player = Player(world, win_size, view)
    # the player is an event-handler for the Window class of pyglet
    # where it gets it's keyboard events
    window.push_handlers(player)

    # the other controller is the AsteroidSpammer
    # whose task is to spam Asteroids
    asteroid_spammer = AsteroidSpammer(world, win_size, view)

    @world.collision_handler(Asteroid, Bullet)
    def begin(arbiter, space, data):
        for shape in arbiter.shapes:
            try:
                model, controller = world.get_by_shape(shape)
                controller.delete(model)
            except KeyError:
                # collision handler gets called multiple times
                # even after deletion it seems
                # this is an error in pymunk/chipmunk
                pass
        return False

    @world.collision_handler(Spaceship, Asteroid)
    def post_solve(arbiter, space, data):
        try:
            for shape in arbiter.shapes:
                model, controller = world.get_by_shape(shape)
                # stop game
                world.done = True
        except KeyError:
            pass

    # the window controls when it is drawn
    @window.event
    def on_draw():
        window.clear()
        # every view is registered with View
        # so View.draw draws everything
        view.draw()

    # everything that needs to be done continually
    # has to be in this function
    def interval_cb(dt):
        # world time has to go on
        world.step(dt)
        # controll of the ship is in world time
        player.step(dt)
        # the AsteroidSpammer may want to spam an Asteroid
        asteroid_spammer.step(dt)

    # now schedule the callback ~30 times per second
    pyglet.clock.schedule_interval(interval_cb, 1/30)

    # finally we are done :)
    # lets run the app
    pyglet.app.run()
Example #31
0
import resources

#setup gameobject and data

window = window.Window(360,640,caption="Lifts.")

gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

objects = []

waitqueue = []

keys = {"up": False, "down": False}

font.add_file('VT323-Regular.ttf')
font.add_file('TulpenOne-Regular.ttf')

floors = []

for i in range(10):
    floors.append(floor.floor(i))

waitTime = {"Opener": 0.0, "Closer": 0.0, "Neutral": 0.0}

endings = {"Opener": u"The Elder Ones are unleashed and the world enters into a new DARK AGE.  Or does it?",
           "Closer": u"The rift is sealed, until another day.  Until then, the everyday tedium, misery and march towards death continues.",
           "Neutral": u"With much regret, but for the greater good, the advance of Machine intelligence is destroyed to protect the Human race.\n\n\u03EE"
           }

avgWaitTime = 0.0
Example #32
0
class Resources:
    states = {
        'TITLE': 1,
        'SETUP': 2,
        'HOST': 3,
        'JOIN': 4,
        'GAME': 5,
        'END': 6
    }  #game states
    types = ['green', 'lblue', 'red', 'mblue']  #player types
    window_width = 800
    window_height = 600
    center_x, center_y = get_center_coordinates(window_width, window_height)

    # Starting Points of Characters (x,y)
    starting_points = {}

    # Object Batches per state #
    batches = {}

    batches['title'] = Batch()
    batches['setup'] = Batch()
    batches['host'] = Batch()
    batches['join'] = Batch()
    batches['game'] = Batch()
    batches['end'] = Batch()
    # End of Batches

    # Declare all of your assets here #
    fonts = {}
    fonts_path = './assets/font'
    font.add_file(join(fonts_path, "nexa.otf"))

    fonts['nexa'] = font.load('Nexa Bold')

    audio = {}
    sfx_path = './assets/sfx'

    #Sound Effects
    audio['title_bgm'] = media.load(join(sfx_path, "title_bgm.wav"))
    audio['end_bgm'] = media.load(join(sfx_path, "end_bgm.wav"))
    audio['game_bgm'] = media.load(join(sfx_path, "game_bgm.wav"))
    audio['button'] = media.load(join(sfx_path, "button.wav"), streaming=False)
    audio['push_all'] = media.load(join(sfx_path, "push.wav"), streaming=False)
    audio['hit_upgrade'] = media.load(join(sfx_path, "hit_upgrade.mp3"),
                                      streaming=False)
    audio['game_win'] = media.load(join(sfx_path, "game_win.mp3"),
                                   streaming=False)
    audio['transition_to_game'] = media.load(
        join(sfx_path, "transition_to_game.mp3"))
    audio['transition_to_end'] = media.load(
        join(sfx_path, "transition_to_end.mp3"))

    sprites = {}
    res_path = './assets/img'

    #UI Elements
    sprites['no_sprite'] = image.load(join(res_path, 'blank.png'))
    sprites['start_button'] = center_image(
        image.load(join(res_path, 'start_button.gif')))
    #sprites['start_button_mv']		= image.load_animation(join(res_path,'start_button.gif'))
    sprites['play_button'] = center_image(
        image.load(join(res_path, 'play_button_shadow.gif')))
    sprites['host_button'] = center_image(
        image.load(join(res_path, 'debug_button.gif')))
    sprites['join_button'] = center_image(
        image.load(join(res_path, 'join_button.gif')))
    sprites['quit_button'] = center_image(
        image.load(join(res_path, 'quit_button.gif')))
    sprites['logo'] = center_image(image.load(join(res_path, 'logo.png')))
    sprites['push_all'] = center_image(
        image.load(join(res_path, 'push_all.png')))
    sprites['marker'] = center_image(image.load(join(res_path, 'marker.png')))
    sprites['push_all'] = center_image(
        image.load(join(res_path, 'push_all.png')))
    sprites['info_bar'] = image.load(join(res_path, 'info_bar.png'))
    sprites['bounces'] = image.load(join(res_path, 'bounces2.png'))
    sprites['powers'] = image.load(join(res_path, 'powers.png'))
    sprites['game_over'] = image.load(join(res_path, 'game_over.png'))
    sprites['game_win'] = image.load(join(res_path, 'game_win2.png'))
    #Thumbnails
    sprites['thumb_green'] = image.load(
        join(res_path, 'thumbnails/thumb_air.png'))
    sprites['thumb_mblue'] = image.load(
        join(res_path, 'thumbnails/thumb_earth.png'))
    sprites['thumb_red'] = image.load(
        join(res_path, 'thumbnails/thumb_fire.png'))
    sprites['thumb_lblue'] = image.load(
        join(res_path, 'thumbnails/thumb_water.png'))
    #Backgrounds
    sprites['title_bg'] = center_image(
        image.load(join(res_path, 'title_bg.jpg')))
    sprites['setup_bg'] = center_image(
        image.load(join(res_path, 'setup_bg.jpg')))
    sprites['game_bg'] = center_image(image.load(join(res_path,
                                                      'game_bg.jpg')))
    #Game Elements
    sprites['char_green'] = center_image(
        image.load(join(res_path, 'char_air.png')))
    sprites['char_mblue'] = center_image(
        image.load(join(res_path, 'char_earth.png')))
    sprites['char_red'] = center_image(
        image.load(join(res_path, 'char_fire.png')))
    sprites['char_lblue'] = center_image(
        image.load(join(res_path, 'char_water.png')))
    sprites['power_up'] = center_image(
        image.load(join(res_path, 'power_up.png')))
    sprites['bounce_up'] = center_image(
        image.load(join(res_path, 'bounce_up.png')))
Example #33
0
from functools import partial
import webbrowser
from pyglet import font

import engine.InferenceEngine as ie
from engine.question.QuestionType import QuestionType as qt

from paths import logo_path, fonts_path

pd.options.mode.chained_assignment = None  # default='warn'

# Fonts work differently on MacOs, just download them there .
if (platform.system() != "Darwin"):
    # Add fonts
    for f in fonts_path.glob("**/*.ttf"):
        font.add_file(os.path.join(fonts_path, f))


# Create the application's frame
class SampleApp(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.geometry('900x630')
        self.title('Perfume Knowledge System')
        self.engine = ie.InferenceEngine()
        self._frame = None
        self.switch_frame(StartPage)
        self.first_name = tk.StringVar()
        self.outcome = tk.StringVar()
        self.widgets = []
        self.chosen_products = []
Example #34
0
from pyglet import font
from os.path import join
from os import getcwd

press_start_2p = 'Press Start 2P'
font.add_file(join('fonts', 'press_start_2p', 'PressStart2P.ttf'))
font.load(press_start_2p)
Example #35
0
def load_font(path):
    p = TruetypeInfo(path)
    p.close()
    font.add_file(path)
Example #36
0
from pyglet import resource, font, image
from pyglet.gl import *

fontname = "Dumbledor 1"
fontname = "MPlantin"
fontname = "Arial"

import ConfigParser
config = ConfigParser.ConfigParser()
config.read("data/incantus.ini")

resource.path.append("./data/images")
resource.path.append("./data/compositing")
resource.path.append("./data/avatars")
resource.path.append("./data/images/fx")
font.add_file("./data/fonts/dum1.ttf")
font.add_file("./data/fonts/MPlantin.ttf")
font.add_file("./data/fonts/MPlantinI.ttf")
font.add_file("./data/fonts/MatrixB.ttf")
font.add_file("./data/fonts/MatrixBSmallCaps.ttf")
font.add_file("./data/fonts/Pixelmix.ttf")

resource.reindex()


class ImageCache(object):
    cache = {}

    @staticmethod
    def get(key):
        return ImageCache.cache.get(key, None)
Example #37
0
def load_fonts():
    for name, d in C.UI.Cocos.Fonts.to_dict().items():
        add_file(os.path.join(SystemDataPath, 'resources', 'fonts', d['File']))
        info('Load {!r} font {!r} from file {!r}'.format(
            name, d['Name'], d['File']))
Example #38
0
import pyglet
from pyglet.window import key, mouse
from UnitIcon import UnitIcon
from Unit import Unit
from EnemyUnit import EnemyUnit
import random
from pyglet import font
import json

scale = 6

pyglet.resource.path = ['../resources']
pyglet.resource.reindex()
font.add_file('../resources/DisposableDroidBB.ttf')
ddbb = font.load("DisposableDroid BB")

window = pyglet.window.Window(1152, 576)


def update(dt):
    if option_arrows[0].x > 28 * scale:
        arrowMove["forward"] = False
    if option_arrows[0].x < 22 * scale:
        arrowMove["forward"] = True

    if commands["assigningUnit"] == True:
        for arrow in option_arrows:
            if arrowMove["forward"] == True:
                arrow.x += 1
            else:
                arrow.x -= 1
Example #39
0
def load_fonts():
    for name, d in C.UI.Cocos.Fonts.to_dict().items():
        add_file(os.path.join(SystemDataPath, 'resources', 'fonts', d['File']))
        info('Load {!r} font {!r} from file {!r}'.format(name, d['Name'], d['File']))
Example #40
0
from pyglet import resource, font, image
from pyglet.gl import *

fontname = "Dumbledor 1"
fontname = "MPlantin"
fontname = "Arial"

import ConfigParser
config = ConfigParser.ConfigParser()
config.read("data/incantus.ini")

resource.path.append("./data/images")
resource.path.append("./data/compositing")
resource.path.append("./data/avatars")
resource.path.append("./data/images/fx")
font.add_file("./data/fonts/dum1.ttf")
font.add_file("./data/fonts/MPlantin.ttf")
font.add_file("./data/fonts/MPlantinI.ttf")
font.add_file("./data/fonts/MatrixB.ttf")
font.add_file("./data/fonts/MatrixBSmallCaps.ttf")
font.add_file("./data/fonts/Pixelmix.ttf")

resource.reindex()

class ImageCache(object):
    cache = {}
    @staticmethod
    def get(key): return ImageCache.cache.get(key,None)
    @staticmethod
    def _load(filename, key, anchor=False):
        cache = ImageCache.cache
Example #41
0
 def __init__(self, handler):
     mode.Renderer.__init__(self, handler)
     font.add_file('resources/amsterdam.ttf')
     self.amsterdam = font.load('Amsterdam Graffiti', 45)
Example #42
0
import pyglet
import keys
import buttons
import presets
import chordGenerator
import copy
from pyglet.window import mouse
from pyglet import font

window = pyglet.window.Window(1280, 720, resizable = False)
keyList = keys.getKeys()
font.add_file('montserrat semibold.otf')

labels = pyglet.graphics.Batch()
toneButtonsBatch = buttons.toneButtonsBatch
keyButtonsBatch = buttons.keyButtonsBatch
chordButtonsBatch = buttons.chordButtonsBatch
presetButtonsBatch = buttons.presetButtonsBatch
speedButtonsBatch = buttons.speedButtonsBatch

tonalityButtons = buttons.tonalityButtons
keyButtons = buttons.keyButtons
chordButtons = buttons.chordButtons
presetButtons = buttons.presetButtons
speedButtons = buttons.speedButtons

logo = pyglet.sprite.Sprite(pyglet.image.load("logo.png"), x = 25, y = 615, batch = labels)
tonalityLabel = pyglet.text.Label("TONALITY", x = 70, y = 605, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels)
keyLabel = pyglet.text.Label("KEY", x = 70, y = 550, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels)
chordLabel = pyglet.text.Label("CHORD", x = 70, y = 495, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels)
presetsLabel = pyglet.text.Label("Presets:", x = 60, y = 35, font_name = 'Montserrat SemiBold', font_size = 24, anchor_x = 'left', anchor_y = 'center', batch = labels)
Example #43
0
        else:
            return False


global ACTIVE_WORD, VIEW_DICT, VIEW_MODE, main_display

INTERFACE_PATH = "/Users/jamesashford/Documents/Projects/Hackathons/Oxford Hack 2020/OxHack-2020/TCARS"
RSC_PATH = f"{INTERFACE_PATH}/rsc"
OUTPUT_PATH = f"{INTERFACE_PATH}/output"
WIDTH, HEIGHT = 1440, 898
ACTIVE_WORD = "ENTER QUERY"
VIEW_MODE = 1
VIEW_DICT = {1: "wordcloud", 2: "coocgraph", 3: "psplot"}

# Load in font
font.add_file(f'{RSC_PATH}/swiss_911_ultra_compressed_bt.ttf')
font.load(f'{RSC_PATH}/swiss_911_ultra_compressed_bt.ttf', 16)

# Generate window for app
window = pyglet.window.Window(WIDTH, HEIGHT, "Twitter Analysis")

# Title and Search Labels
title = pyglet.text.Label("TCARS",
                          font_name='Swiss911 UCm BT',
                          font_size=90,
                          x=150,
                          y=800,
                          width=250,
                          height=100,
                          anchor_x='left',
                          anchor_y='bottom')
Example #44
0
import pyglet
from window import MainWindow
from pyglet import gl, font

# Retrieve font from local folder
font.add_file('assets/fonts/Arimo-Regular.ttf')
font.load('Arimo')

# Globally accessible variable
win = MainWindow()

# Allow transparency calculations
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

# Debug all events
# win.push_handlers(pyglet.window.event.WindowEventLogger())

# Main application loop
pyglet.app.run()
Example #45
0
import pyglet
from pyglet import font
font.add_file('montserrat regular.otf')

class toneButton():
	def __init__(self, xCoord, text, buttons):
		self.x = xCoord
		self.y = 605
		self.label = pyglet.text.Label(text, x = xCoord, y = 605, font_name = 'Montserrat', font_size = 24, anchor_x = 'center', anchor_y = 'center', batch = buttons)

	def on(self,x,y):
		if (self.x - 50 <= x <= self.x + 50) and(self.y - 15 <= y<= self.y +25):
			return True
		else:
			return False

def resetTone(tonelist, i):
	for x in range(len(tonelist)):
		if x != i:
			tonelist[x].label.font_size = 24
			tonelist[x].label.color = (255,255,255,255)

class keyButton():
	def __init__(self, xCoord, text, buttons, type):
		self.x = xCoord
		self.y = 550
		self.type = type # how large is 
		self.label = pyglet.text.Label(text, x = xCoord, y = 550, font_name = 'Montserrat', font_size = 24, anchor_x = 'center', anchor_y = 'center', batch = buttons)

	def on(self,x,y):
		if self.type == 0: