def __init__(self, resolution, flags): GraphicEngine.__init__(self) pygame.init() pygame.font.init() self._screen = pygame.display.set_mode(resolution, flags) self._clock = pygame.time.Clock() self._font = pygame.font.Font(None, 40) # for examples TODO: find a better way self._img_path = '../data/pix'
def __init__(self, resolution, caption): GraphicEngine.__init__(self) # for examples TODO: find a better way pyglet.resource.path.append('../data/pix') # for games: standard path pyglet.resource.path.append('data/pix') pyglet.resource.reindex() self._win = pyglet.window.Window(resolution[0], resolution[1], caption=caption) self._fps_display = pyglet.clock.ClockDisplay()
def display_context(self, screen, context): # clipping according to screen geometry x, y, width, height = screen.geometry glViewport(x, y, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glOrtho(x, x + width, y, y + height, -1, 1) glMatrixMode(GL_MODELVIEW) GraphicEngine.display_context(self, screen, context)
def display_sprite(self, screen, sprite): res = GraphicEngine.display_sprite(self, screen, sprite) self._screen.blit(*res)
def display_sprite(self, screen, sprite): sprite, dst_pos, src_rect = GraphicEngine.display_sprite(self, screen, sprite) dst_pos[1] = self._invert_y_axis(sprite.height, dst_pos[1]) sprite.set_position(*dst_pos) sprite.draw()