Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_attributed(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
def __init__(self, *args, **kwargs):
super(TestWindow, self).__init__(*args, **kwargs)
self.batch = graphics.Batch()
self.document = text.decode_text(doctext)
self.margin = 2
self.layout = layout.IncrementalTextLayout(self.document,
self.width - self.margin * 2, self.height - self.margin * 2,
multiline=True,
batch=self.batch)
self.caret = caret.Caret(self.layout)
self.push_handlers(self.caret)
self.set_mouse_cursor(self.get_system_mouse_cursor('text'))
Optional rendering group to parent all groups this text layout
uses. Note that layouts with different
rendered simultaneously in a batch.
`wrap_lines` : bool
If True and `multiline` is True, the text is word-wrapped using
the specified width.
'''
self.content_width = 0
self.content_height = 0
self.groups = {}
self._init_groups(group)
if batch is None:
batch = graphics.Batch()
self._own_batch = True
self.batch = batch
self._width = width
if height is not None:
self._height = height
if multiline:
self._multiline = multiline
self._wrap_lines_flag = wrap_lines
self._wrap_lines_invariant()
if dpi is None:
dpi = 96
self._dpi = dpi
self.document = document
def __init__(self, width, height, arm_info, point_info, point_l, mouse_in):
super(Viewer, self).__init__(width, height, resizable=False, caption='Arm', vsync=False) # vsync=False to not use the monitor FPS
self.set_location(x=80, y=10)
pyglet.gl.glClearColor(*self.color['background'])
self.arm_info = arm_info
self.point_info = point_info
self.mouse_in = mouse_in
self.point_l = point_l
self.center_coord = np.array((min(width, height)/2, ) * 2)
self.batch = pyglet.graphics.Batch()
arm1_box, arm2_box, point_box = [0]*8, [0]*8, [0]*8
c1, c2, c3 = (249, 86, 86)*4, (86, 109, 249)*4, (249, 39, 65)*4
self.point = self.batch.add(4, pyglet.gl.GL_QUADS, None, ('v2f', point_box), ('c3B', c2))
self.arm1 = self.batch.add(4, pyglet.gl.GL_QUADS, None, ('v2f', arm1_box), ('c3B', c1))
self.arm2 = self.batch.add(4, pyglet.gl.GL_QUADS, None, ('v2f', arm2_box), ('c3B', c1))
def __init__(self, actions, x, y, ui):
self.vis_sound = pyglet.resource.media('sound/options_appear.wav', streaming=False)
self.visible = False
self.actions = actions
self.x = x
self.y = y
# JK LOL
self.x, self.y = 0, 0
self.hide_on_click_outside = True
self.ui = ui
self.background_sprite = pyglet.sprite.Sprite(
pyglet.resource.image('ui/options_box_red.png'),
x=0, y=0)
self.batch = pyglet.graphics.Batch()
self.buttons = []
self.labels = set()
rects = [(90, 138, 330, 40), (455, 130, 380, 40), (880, 138, 330, 40),
(90, 70, 330, 40), (455, 70, 380, 40), (880, 70, 330, 40)]
self.sound_for_callback = {}
for i, (text, callback) in enumerate(self.actions.viewitems()):
rect = rects[i]
self.sound_for_callback[callback] = pyglet.resource.media('sound/select_%d.wav' % (i+1),
streaming=False)
self.buttons.append((rect, callback))
self.labels.add(pyglet.text.Label("%d: %s" % (i+1, text), multiline=True,
font_name=['Synchro LET', 'Verdana', 'Helvetica'],
x=rect[0], y=rect[1], width=rect[2], height=rect[3],
def __init__(self, window, batch=None, group=None):
super().__init__()
self.__window = window
self.__batch = batch or pyglet.graphics.Batch()
self._regroup(group)
self.__spurious_leave_event = False
window.push_handlers(self)
def build(self, batch=None, group=None):
''' Build rectangle and add it to batch and group.
:Parameters:
`batch` : `Batch`
Optional graphics batch to add the object to.
`group` : `Group`
Optional graphics group to use.
'''
self._batch = batch or self._batch or pyglet.graphics.Batch()
self._group = group or self._group
if self._colors[3] == 0:
return
if self._vertices:
self.delete()
x,y = int(self._position[0]), int(self._position[1])
w,h = int(self._size[0]), int(self._size[1])
if self._filled:
self._vertices = self._batch.add(4, gl.GL_QUADS, self._group,
('v2f', (x,y,x+w,y,x+w,y-h,x,y-h)),
('c4B', self._colors))
else:
x,y = x+.315, y-.315
def __init__(self):
self.my_batch = pyglet.graphics.Batch()
self.all_images = [
pyglet.image.load("square-1.png"),
pyglet.image.load("square-2.png"),
pyglet.image.load("square-3.png"),
pyglet.image.load("square-4.png"),
pyglet.image.load("square-5.png"),
]
self.all_sprites = []
self.render()
def __init__(self, game_handler):
super(SceneHandler, self).__init__()
self.scene = None # Main scene
self.scenes = [] # Scenes to be drawn
self.handler = game_handler
self.controller = interpolator.InterpolatorController()
self.fade_time = 1.0
self.batch = pyglet.graphics.Batch()
# Build transition sprite(s)
scene_transition_img = util.load_image(util.respath('environments', 'transitions', 'test.png'))
self.sprite = pyglet.sprite.Sprite(scene_transition_img, x = 0, y = 0, batch=self.batch)
self.sprite.opacity = 0
# A cat has nine lives.
import pyglet
import sys
from game import resources, load
from game import player, rat, catfood, drycatfood, fish, goldfish, mice, milk, woolenball, tinfood
game_window = pyglet.window.Window(800, 600)
game_window.set_caption("~ Grizzly Games ~")
# white color background.
pyglet.gl.glClearColor(1.0,1.0,1.0,1.0)
main_batch = pyglet.graphics.Batch()
score_label = pyglet.text.Label(text="Lives Captured: 0", font_size = 10,
bold=True, x = 50, y = 535,
color = (100,100,155,155), batch = main_batch)
level_label1 = pyglet.text.Label(text=u"Capture (← ↑ ↓ → ) without hitting barb in 1 min.", font_size=10,
bold=True, x = 50, y = 520,
color = (100, 100, 155, 155),batch = main_batch)
level_label = pyglet.text.Label(text=u"A cat has nine lives. :o)", font_size=10,
bold=True, x = 650, y = 535,
color = (0, 0, 0, 100), anchor_x = 'center', batch = main_batch)
def update_score(items):
global score_label
score_label.delete()
score = "Lives Captured: %s" % str(items)