Пример #1
0
    def test_autoinit_and_autoquit(self):
        pygame.init()
        self.assertTrue(ft.was_init())
        pygame.quit()
        self.assertFalse(ft.was_init())

        # Ensure autoquit is replaced at init time
        pygame.init()
        self.assertTrue(ft.was_init())
        pygame.quit()
        self.assertFalse(ft.was_init())
Пример #2
0
    def test_autoinit_and_autoquit(self):
        pygame.init()
        self.assertTrue(ft.was_init())
        pygame.quit()
        self.assertFalse(ft.was_init())

        # Ensure autoquit is replaced at init time
        pygame.init()
        self.assertTrue(ft.was_init())
        pygame.quit()
        self.assertFalse(ft.was_init())
Пример #3
0
 def test_resolution(self):
     was_init = ft.was_init()
     if not was_init:
         ft.init()
     try:
         ft.set_default_resolution()
         resolution = ft.get_default_resolution()
         self.assertEqual(resolution, 72)
         new_resolution = resolution + 10
         ft.set_default_resolution(new_resolution)
         self.assertEqual(ft.get_default_resolution(), new_resolution)
         ft.init(resolution=resolution+20)
         self.assertEqual(ft.get_default_resolution(), new_resolution)
     finally:
         ft.set_default_resolution()
         if was_init:
             ft.quit()
Пример #4
0
# try:
import glob

import pygame
from pygame import freetype

from vec2d import Vec2D
from load import load_image

# except ImportError as message:
    # raise SystemExit(message)

if not freetype.was_init():
    freetype.init()

if not pygame.font.get_init():
    pygame.font.init()


class Button(pygame.sprite.Sprite):

    """Button with a set look and changeable label, centered in the button.
    Gets highlighted when flagged by a keyboard button.

    """

    def __init__(self, label, position=Vec2D(0, 0)):
        """Initialize all attributes and run the initial update.
        Changes in the font may cause a label that was fitting the button
        to not do so anymore.