Exemplo n.º 1
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)
   resource.add_font(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)
Exemplo n.º 2
0
from math import sin, radians
import pyglet
import random
import scene

from pyglet.gl import *
from pyglet import resource

window = pyglet.window.Window(1024, 768)

resource.path.append('../fonts/')
resource.path.append('../res/')
resource.reindex()

resource.add_font('LOKISD__.TTF')

class Title(scene.Scene):
    def __init__(self):
        offset = 50
        self.tick = 0
        self.letters = []

        self.batch = pyglet.graphics.Batch()

        colors = [
            (252, 182, 83, 255),
            (255, 82, 84, 255),
            (206, 232, 121, 255)
        ]
Exemplo n.º 3
0
    if show_fps:
        fps_display.draw()


# --------------------------------------------------------------------------
# Load resources
# --------------------------------------------------------------------------

batch = pyglet.graphics.Batch()
wrapping_batch = pyglet.graphics.Batch()

resource.path.append('res')
resource.reindex()

resource.add_font('saved_by_zero.ttf')

asteroid_sizes = [AsteroidSize('asteroid1.png', 100),
                  AsteroidSize('asteroid2.png', 50),
                  AsteroidSize('asteroid3.png', 10)]
for small, big in map(None, asteroid_sizes[:-1], asteroid_sizes[1:]):
    big.next_size = small

bullet_image = resource.image('bullet.png')
center_anchor(bullet_image)

smoke_images_image = resource.image('smoke.png')
smoke_images = pyglet.image.ImageGrid(smoke_images_image, 1, 8)
map(center_anchor, smoke_images)
smoke_animation = \
    pyglet.image.Animation.from_image_sequence(smoke_images,
Exemplo n.º 4
0
"""Data loaders.

Add functions here to load specific types of resources.

"""

import os
import sys

from pyglet import font
from pyglet import resource

import config
from common import *
from constants import *

resource.path = ["data/" + subdir for subdir in ['fonts', 'images', 'music', 'sounds']]
resource.reindex()

resource.add_font('DejaVuSans.ttf')
resource.add_font('DejaVuSans-Bold.ttf')
Exemplo n.º 5
0
    log_err('you have not registered, exit')
    exit(1)

path['log'] = join(path['mcpypath'], 'log')
path['texture'] = join(path['pack'], 'texture')
path['texture.hud'] = join(path['texture'], 'hud')
path['texture.ui'] = join(path['texture'], 'ui')
path['save'] = join(path['mcpypath'], 'save')
path['screenshot'] = join(path['mcpypath'], 'screenshot')

lang = json.load(
    open(join(path['lang'], settings['lang'] + '.json'), encoding='utf-8'))
get_lang = lambda s: lang[s] if s in lang else s

resource.path = [join(path['pack'])]
resource.reindex()
resource.add_font('minecraft.ttf')

args_o = False
libs = []
for args in sys.argv:
    if args == '-o':
        args_o = True
    if args_o and args != '-o':
        if isdir(join(lib_path, args)) or isfile(join(lib_path, args + '.py')):
            log_info('loading lib: %s' % args)
            libs.append(__import__(args))
        else:
            log_warn("No lib '%s' found, exit" % args)
            exit(1)
Exemplo n.º 6
0
import pyglet
from pyglet import font
from pyglet import resource

window = pyglet.window.Window(width=500, height=500)

resource.add_font('HWHP.ttf')
action_man = font.load('HWHP')
label = pyglet.text.Label(x=100,
                          y=100,
                          text='你好',
                          font_size=50,
                          font_name='Hello',
                          color=(255, 0, 0, 255))


@window.event
def on_draw():
    window.clear()
    label.draw()


if __name__ == '__main__':
    pyglet.app.run()