Example #1
0
def init():
    global RsScreen, RsRoom

    pygame.init()
    PyDisplay.init()
    PyDisplay.set_caption("Real Space")
    PyDisplay.set_allow_screensaver(False)
    RsScreen = PyDisplay.set_mode(RsConstants.Resolutions)

    # Startup
    Game.init()
    Rooms = RsContainers.RoomOrder
    RsRoom = Rooms[0]
    if not RsRoom:
        raise RuntimeError("No scene found.")

    absolute_timer = Clock()

    # Load rooms
    print(RsRoom)
    RsRoom.onAwake()
    while True:
        frame_time: int = 0 if RsRoom.paused else absolute_timer.get_time()
        RsScreen.fill(RsConstants.c_black)

        asyncio.run(event_collect())
        asyncio.run(scene_update(RsRoom, frame_time))

        PyDisplay.flip()
        absolute_timer.tick()
Example #2
0
def main(argv=[]):
    display.init()
    joystick.init()

    if len(argv) > 1:
        for sz in argv[1:]:
            try:
                joystick.Joystick(int(sz)).init()
            except:
                pass
    else:
        for i in xrange(joystick.get_count()):
            joystick.Joystick(i).init()

    e = event.wait()
    while e.type != QUIT:
        if e.type == JOYAXISMOTION:
            print 'js', e.joy, 'axis', e.axis, round(e.value, P)
        elif e.type == JOYBALLMOTION:
            print 'js', e.joy, 'ball', e.ball, round(e.rel, P)
        elif e.type == JOYHATMOTION:
            print 'js', e.joy, 'hat', e.hat, h[e.value]
        elif e.type == JOYBUTTONUP:
            print 'js', e.joy, 'button', e.button, 'up'
        elif e.type == JOYBUTTONDOWN:
            print 'js', e.joy, 'button', e.button, 'down'
        e = event.wait()
Example #3
0
    def __init__(self, arbalet, runtime_control):
        """
        Simple event manager duplicating the pygame events for the system (runtime hardware management) and the user (game control)
        The get() method and the system-reserved _get() both poll the pygame event list to keep the list up-to-date and also avoid the pygame internal queue to be full
        TODO: events pygame/touch to be merged into a unique format
        :param enable_system_events: enable the acquisition of system events, must be False if no Arbalink polls the system event queue
        :return:
        """
        Thread.__init__(self)
        self.setDaemon(True)
        self._system_events = []
        self._user_events = []
        self._user_events_lock = RLock()
        self._arbalet = arbalet
        self._rate = Rate(self._arbalet.config['refresh_rate'])
        self._runtime_control = runtime_control
        self.running = False

        # All joysticks are enabled by default
        with self._arbalet.sdl_lock:
            display.init()
            joystick.init()
            for j in range(joystick.get_count()):
                joy = joystick.Joystick(j)
                joy.init()

        self.start()
Example #4
0
	def __init__(self, resolution, world, viewport=None):
		pgdisplay.init()
		self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF)
		# self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF|pg.FULLSCREEN)
		pgdisplay.set_caption('PyAudioEffect')
		self.world = world
		self.viewport = viewport
Example #5
0
    def test_init(self):
        """Ensures the module is initialized after init called."""
        # display.init() already called in setUp(), so quit and re-init
        display.quit()
        display.init()

        self.assertTrue(display.get_init())
Example #6
0
 def __init__(self, width, height, fullimage, starting_position=(0, 0)):
     if not display.get_init():
         display.init()
     self.width = width
     self.height = height
     self.image = image.load(fullimage).convert()
     self.rect = self.image.get_rect()
Example #7
0
 def initDisplay(self):
     """Initiazlizes the screen in pygame with the screen object variables.
     """
     display.init()
     self.surface = display.set_mode([self.width, self.height])
     self.clearScreen()
     self.update()
Example #8
0
 def main():
     display.init()
     maxX,maxY = display.list_modes()[0] 
     screen = display.set_mode( (maxX/3, maxY/3 ) )
     
     display.flip()
     
     pgw = PygameWidget( )
     p = Player( pgw, pipe_desc=Player.test_pipe_desc )
     p.play()
     
     clock = pygame.time.Clock()
     
     running = True
     while running:
         clock.tick( 60 )
         for evt in [pygame.event.wait()] + pygame.event.get():
             if evt.type == pygame.KEYDOWN:
                 if p._playing:
                     p.pause()
                 else:
                     p.play()
             elif evt.type == pygame.QUIT:
                 p.stop()
                 running = False
Example #9
0
    def __init__( self, port=65001, rate=10 ):
        """
        Initialize pygame based joystick interface
        
        INPUTS: 
          port -- int -- udp port for communication
          mode -- string -- either 0 which pushes events out
                                or 1 which polls at a given rate
          rate -- float -- polling frequency 
        """
	self.DEBUG = []	

        self.port = port
        self.rate = rate
    
        # Initialize socket
        self.sock = socket(AF_INET, SOCK_DGRAM)
        
        display.init()
        # Initialize joystick object
        joystick.init()
        num_joys = joystick.get_count()
        if num_joys < 1:
            print "No joysticks detected"
            exit
        self.j = joystick.Joystick(0)
        self.j.init()
        self.t0 = now()
Example #10
0
    def __init__(self, id=0, deadzone=.2):
        '''
        Creats controller object
        '''
        display.init()
        joystick.init()
        self.joystick = joystick.Joystick(id)
        self.joystick.init()
        self.deadzone = deadzone

        # Controller Pressed Values
        self.A = 0
        self.B = 0
        self.X = 0
        self.Y = 0
        self.LB = 0
        self.RB = 0
        self.SELECT = 0
        self.START = 0
        self.XBOX = 0
        self.LS = 0
        self.RS = 0
        self.LX = 0
        self.LY = 0
        self.LT = 0
        self.RT = 0
        self.RX = 0
        self.RY = 0
        self.DX = 0
        self.DY = 0
Example #11
0
 def __init__(self, resolution, world, viewport=None):
     pgdisplay.init()
     self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF)
     # self.screen = pgdisplay.set_mode(resolution, pg.DOUBLEBUF|pg.FULLSCREEN)
     pgdisplay.set_caption('PyAudioEffect')
     self.world = world
     self.viewport = viewport
Example #12
0
    def main():
        display.init()
        maxX, maxY = display.list_modes()[0]
        screen = display.set_mode((maxX / 2, maxY / 2))
        background = pygame.Surface(screen.get_size())
        background = background.convert()
        background.fill((255, 255, 255))

        screen.blit(background, (0, 0))
        display.flip()

        clock = pygame.time.Clock()

        font = PangoFont(size=30, family='monospace')
        text1 = font.render('red',
                            color=(255, 0, 0),
                            background=(255, 255, 255, 0))
        text2 = font.render('green', color=(0, 255, 0))
        text3 = font.render('blue', color=(0, 0, 255))
        text4 = font.render('blue-trans', color=(0, 0, 255, 128))
        text5 = font.render('cyan-trans', color=(0, 255, 255, 128))
        while 1:
            clock.tick(60)
            for event in pygame.event.get():
                log.debug('event: %s', event)
                if event.type == pygame.QUIT:
                    return True
            screen.blit(text1, (20, 20))
            screen.blit(text2, (20, 80))
            screen.blit(text3, (20, 140))
            screen.blit(text4, (200, 20))
            screen.blit(text5, (200, 80))
            display.flip()
    def __init__(self, audioManger, imageDrawer, title="Window", icon=None):
        self.Running = True
        self.DebugMode = False

        display.init()
        pygame.font.init()
        pygame.init()
        self.ScaleFactor = 1
        self.AudioPlayer = audioManger
        self.Drawer = imageDrawer

        pygame.display.set_icon(self.Drawer.GetRawImage(icon))
        pygame.display.set_caption(title)

        info = pygame.display.Info()
        self.Resolution = [378, 704]
        self.SystemResolution = [info.current_w, info.current_h]
        self.UpdateWindowSize()

        self.PieceList = []
        self.Selectable = []
        self.MouseStartPos = None
        self.SelectIndex = 0
        self.OperationSetUpIndex = None
        self.Clock = pygame.time.Clock()
        return
Example #14
0
    def main():
        display.init()
        maxX, maxY = display.list_modes()[0]
        screen = display.set_mode((maxX / 3, maxY / 3))

        display.flip()

        pgw = PygameWidget()
        p = Player(pgw, pipe_desc=Player.test_pipe_desc)
        p.play()

        clock = pygame.time.Clock()

        running = True
        while running:
            clock.tick(60)
            for evt in [pygame.event.wait()] + pygame.event.get():
                if evt.type == pygame.KEYDOWN:
                    if p._playing:
                        p.pause()
                    else:
                        p.play()
                elif evt.type == pygame.QUIT:
                    p.stop()
                    running = False
Example #15
0
    def init(self):
        # buggy on some OSX boxen.
        #environ['SDL_VIDEO_WINDOW_POS'] = '0,0'

        environ['SDL_VIDEO_CENTERED'] = '1'
        self.fullscreen = False
        display.init()
        self.set_mode()
Example #16
0
    def init(self):
        # buggy on some OSX boxen.
        #environ['SDL_VIDEO_WINDOW_POS'] = '0,0'

        environ['SDL_VIDEO_CENTERED'] = '1'
        self.fullscreen = False
        display.init()
        self.set_mode()
Example #17
0
 def init_display(self) -> None:
     pygame.init()
     display.init()
     self.init_main_surface()
     self.init_game_surface()
     # debug is pretty sketch tbh but it's helpful
     if self.debug:
         self.init_console_surface()
         self.init_registers_surface()
Example #18
0
def main():
    print "#"*31
    print "### Welcome to MindMixer ###"
    print "####### Version 0.1beta #######"
    print """Have a look at the sourcecode!
Change stuff to suit your needs!
The program will hopefully be
self explaining. Hafe fun!"""
    print "#"*31
    selftests()
    global N
    while 1:
        print "(Hint: while training, you can hit SPACE to abort)"
        print "Hit '"+KEYLEFT+"' if the",str(N)+". previous image is identical to the one shown"
        print "Hit '"+KEYRIGHT+"' if the",str(N)+". previous sound is identical to the one heard"
        while 1:
            print "Ready to train with N=%i?" %(N),
            if ask():
                break
            else:
                print "Do you wish to train with N set to a different value? Choosing 'No' exits the program.",
                if ask():
                    n = int(raw_input("Ok, enter the desired value here: "))
                    while n < 1:
                        print "N must be 1 or higher!"
                        n = int(raw_input("Enter a value higher than 1: "))
                    N = n
                else:
                    print "bye"
                    sys.exit(1)
                
        display.init()
        display.set_mode(RESOLUTION, FULLSCREEN)
        font.init()
        mixer.init(44100)
        event.set_grab(True)
        mouse.set_visible(False)
        trials = gentrials()
        for trial in trials:
            if not trial.runtrial():
                break
        display.quit()
        vis = 0.0
        acu = 0.0
        for trial in trials:
            if trial.result[0]:
                vis+=1
            if trial.result[1]:
                acu+=1
        vp = (vis/(MINTRIALS+N))*100
        ap = (acu/(MINTRIALS+N))*100
        message = "percentage in visual modality:%i\npercentage in acoustic modality:%i\n" %(int(vp),int(ap))
        print message
        if vp >= UPPERTH and ap >= UPPERTH:
            N+=1
        elif (vp < LOWERTH or ap < LOWERTH) and N > 1:
            N-=1
Example #19
0
    def __init__(self, game):
        self.game = game
        self.viewport = None
        display.init()
        font.init()
        self.fonter = font.SysFont('monospace', 16)

        self.screen = display.set_mode((config.screenW, config.screenH), DOUBLEBUF, 32)
        display.set_caption("Smash the tanks!")
    def __init__(self):
        os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (50, 50)
        display.init()
        pygame.font.init()
        self.SettingSetup()

        self.object3D_list = []

        return
Example #21
0
 def __init__(self):
     display.init()
     fastevent.init()
     self.tela = display.set_mode((640, 640))
     display.set_caption("ClayMan")
     self.FPS_TICK = time.Clock()
     self.GAMELOOP = True
     self.map_generator = OgmoMap("res/map/NewLevel0.json",
                                  "res/CreyMan.png")
Example #22
0
def init():
    state = 0
    display.init()
    font.init()
    settings = load_settings_file()
    screen = display.set_mode(settings.frame_resolution, DOUBLEBUF)
    display.set_caption("beeSim")
    display.set_icon(game_icon)

    return state, screen, settings
    def __init__(self):
        os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (50, 50)
        display.init()
        pygame.font.init()
        self.SettingSetup()
        self.Running = True

        self.PieceList = []

        return
Example #24
0
        def __init__(self):

            D.init()
            F.init()
            D.set_mode((0, 0), pygame.NOFRAME)
            self.main_surface = D.get_surface()
            background = I.load("DB.jpg").convert()
            self.main_surface.blit(background, (0, 0))
            D.flip()
            D.set_caption("DIVE")
Example #25
0
 def __init__(self, width, height, fullimage, starting_position=(0, 0)):
     if not display.get_init():
         display.init()
     self.full_image = image.load(fullimage)
     self.width = width
     self.height = height
     self.x_sprites = self.full_image.get_width() / self.width
     self.y_sprites = self.full_image.get_height() / self.height
     self.update_current((0, 0, self.width, self.height))
     self.rect = self.image.get_rect()
     self.rect.topleft = starting_position
Example #26
0
    def __init__(self, start=True, **kw):
        super().__init__(**kw)
        display.init()
        mouse.set_visible(False)

        self.size = self.canvas.array.shape[:2]
        self.screen = display.set_mode(self.size)
        self.screen.fill((0, 0, 0))

        if start:
            self.start()
Example #27
0
	def __init__(self, SCREEN):
		# Initiate pygame and display.
		init()
		display.init()
		display.set_caption('The Platformer')
		# Create fps and set main display.
		self.fpsClock = time.Clock()
		self.mainDisplay = display.set_mode(SCREEN)

		# Level
		self.level_1 = Level()		
Example #28
0
 def __init__(self, module_path, proxy_url, player_key):
     global_environment.update(load(module_path))
     self.proxy_url = proxy_url
     self.player_key = player_key
     global_environment[Symbol("send")] = self.send
     self.width, self.height = 320, 240
     display.init()
     self.screen = display.set_mode((self.width * 4, self.height * 4))
     print("display flags", bin(self.screen.get_flags()))
     global_environment[Symbol("draw")] = self.draw
     global_environment[Symbol("multipledraw")] = self.multipledraw
Example #29
0
 def __init__(self,
              scale_factor,
              screen_width=SCREEN_WIDTH,
              screen_height=SCREEN_HEIGHT):
     self.scale_factor = scale_factor
     display.init()
     self.surface = display.set_mode(
         (screen_width * scale_factor, screen_height * scale_factor),
         DOUBLEBUF, SCREEN_DEPTH)
     display.set_caption('CHIP8 Emulator')
     self.clear_screen()
     display.flip()
Example #30
0
def test_core_intro():
    """Test Introduction."""
    display.init()
    mixer.init()
    display.set_mode(SCREEN_SIZE)

    images = collect_images()
    intro = Introduction(images)

    intro.start_events(None)
    intro.update()
    intro.draw()
Example #31
0
    def _InitializeComponents(self, frequency, channels):

        # Initialize pygame.

        font.init()

        display.init()

        mixer.pre_init(frequency)
        mixer.init()
        mixer.set_num_channels(channels)

        mouse.set_visible(False)
Example #32
0
    def __init__(self, buffer, width, height, map, pygame=False):
        '''
        simulate the micropython framebuffer class to test the gui library
        with normal python on a PC
        '''
        self.buffer = buffer
        self.width = width
        self.height = height

        self.surf = None
        if pygame and display is not None:
            display.init()
            self.surf = display.set_mode((width, height + 2))
Example #33
0
 def initialize_display(self):
     """
     Initialize pygame display.
     :return: None
     """
     display.init()
     width = self.width * self.scale
     height = self.height * self.scale
     size = (width, height)
     self.window = display.set_mode(size)
     display.set_caption('CHIP8 Emulator')
     self.clear_screen()
     self.update_display()
Example #34
0
 def __init__(self):
     font.init()
     display.init()
     # init screen
     self.raw_w, self.raw_h = len(
         FIELD[0]) * TILE_scale, len(FIELD) * TILE_scale
     self.scale = 1
     self.resolution = int(self.raw_w * self.scale), int(self.raw_h *
                                                         self.scale)
     self.display_surface = display.set_mode(self.resolution, FULLSCREEN)
     # init a debug font
     self.debug_font = font.Font(font.get_default_font(), 10)
     self.effect_smoke = []
Example #35
0
 def init_display(self):
     """
     Attempts to initialize a screen with the specified height and width.
     The screen will by default be of depth SCREEN_DEPTH, and will be
     double-buffered in hardware (if possible).
     """
     display.init()
     self.surface = display.set_mode(((self.width * self.scale_factor),
                                      (self.height * self.scale_factor)),
                                     HWSURFACE | DOUBLEBUF, SCREEN_DEPTH)
     display.set_caption('CHIP8 Emulator')
     self.clear_screen()
     self.update()
Example #36
0
def test_generic():
    """Test the generic class."""
    display.init()
    mixer.init()
    screen = display.set_mode(SCREEN_SIZE)

    images = collect_images()
    images["final"] = images["backgrounds"]["win"]
    generic = Generic(images)

    for event in pygame.event.get():
        generic.start_events(event)
    generic.update()
    generic.draw()
Example #37
0
def test_core_game():
    """Test Game."""
    font.init()
    display.init()
    mixer.init()
    screen = display.set_mode(SCREEN_SIZE)

    images = collect_images()
    game = Game(images)

    for event in pygame.event.get():
        game.start_events(event)
    game.update()
    game.draw()
Example #38
0
 def __init__(self, width, height, scale, shared_buffer) -> None:
     self.width = width
     self.height = height
     self.scale = scale
     self.buffer = shared_buffer
     self.frame = framebuf.FrameBuffer(shared_buffer, width, height, framebuf.MONO_VLSB)
     self.window_size = (width * scale, height * scale)
     pyg_display.init()
     pyg_display.set_caption("SSD1306_EMU")
     self.surface = pyg_display.set_mode(self.window_size, flags=L.DOUBLEBUF|L.HWSURFACE, vsync=1)
     self.clock = Clock()
     self.invert = False
     self.contrast = 255
     self.power = True
Example #39
0
    def __init__(self, naubino):
        super(Application, self).__init__()
        self.naubino = naubino
        naubino.app  = self
        self.__update_objects = []
        self.__items = []
        self.__objs_graphics = {}
        
        display.init()
        screen = self.screen = display.set_mode((600, 400))
        pygame.time.set_timer(pygame.USEREVENT+1, 20)

        screen.fill(pygame.Color(255, 255, 255))
        display.flip()
        self.paint()
Example #40
0
 def init_display(self):
     """
     Attempts to initialize a screen with the specified height and width.
     The screen will by default be of depth SCREEN_DEPTH, and will be
     double-buffered in hardware (if possible).
     """
     display.init()
     self.surface = display.set_mode(
         ((self.width * self.scale_factor),
          (self.height * self.scale_factor)),
         HWSURFACE | DOUBLEBUF,
         SCREEN_DEPTH)
     display.set_caption('CHIP8 Emulator')
     self.clear_screen()
     self.update()
Example #41
0
    def __init__(self):
        display.init()
        font.init()
        mixer.init(buffer=0)
        self.screen_size = [800, 500]
        self.surface = display.set_mode(self.screen_size)

        life_image = image.load(Utils.get_path("image/icon.png")).convert_alpha()
        display.set_icon(life_image)
        display.set_caption("Ping Pong")
        display.set_icon(life_image)

        self.theme_sound = mixer.Sound(Utils.get_path("sound/menu-screen-theme.wav"))
        self.theme_sound.set_volume(0.25)
        if Setting.MUSIC:
            self.theme_sound.play(-1)

        self.switch_screen(Setting.MENU_SCREEN)
Example #42
0
 def __init__(self, dimensions=(640,480), player=None):
     """Takes a coordinate pair (x,y) as dimensions, and constructs
     a screen on which all objects are displayed."""
     self.dimensions = dimensions
     pygame.init()
     display.init()
     display.set_caption("Dungeon-RPG")
     self.surface = display.set_mode(dimensions)
     self.surface.fill((0,255,0))
     self.background = self.surface.copy()
     self.gameobjects = []
     self.rect = pygame.Rect((0,0), self.dimensions)
     self.player = player
     #we only will update the dirty_objs to boost our speeds
     self.dirty_objs = []
     self.dirty_rects = []
     #refresh the background the first time through:
     self.add_to_dirty_rects(self.rect)
Example #43
0
    def test_issue_208(self):
        """PATCH: pygame.scrap on X11, fix copying into PRIMARY selection

           Copying into theX11 PRIMARY selection (mouse copy/paste) would not
           work due to a confusion between content type and clipboard type.

        """

        from pygame import display, event, freetype
        from pygame.locals import SCRAP_SELECTION, SCRAP_TEXT
        from pygame.locals import KEYDOWN, K_y, QUIT

        success = False
        freetype.init()
        font = freetype.Font(None, 24)
        display.init()
        display.set_caption("Interactive X11 Paste Test")
        screen = display.set_mode((600, 200))
        screen.fill(pygame.Color("white"))
        text = "Scrap put() succeeded."
        msg = (
            "Some text has been placed into the X11 clipboard."
            " Please click the center mouse button in an open"
            " text window to retrieve it."
            '\n\nDid you get "{}"? (y/n)'
        ).format(text)
        word_wrap(screen, msg, font, 6)
        display.flip()
        event.pump()
        scrap.init()
        scrap.set_mode(SCRAP_SELECTION)
        scrap.put(SCRAP_TEXT, text.encode("UTF-8"))
        while True:
            e = event.wait()
            if e.type == QUIT:
                break
            if e.type == KEYDOWN:
                success = e.key == K_y
                break
        pygame.display.quit()
        self.assertTrue(success)
Example #44
0
    def initWindow(self, size = None):
        if (size == None):
            self.size = Config.screen_size
        display.init()
        font.init()
        self.screen = display.set_mode(
            self.size,
            flags.FULLSCREEN if Config.fullscreen else flags.RESIZABLE
        )
        display.set_caption(Config.screen_caption)

        #Initializing bachground surface
        self.background = Surface(self.size).convert()
        self.background.fill(Config.background_color)

        #Initializing raycast engine
        self.raycast = Raycast(self.size)

        self.loadTextures()

        self.default_font = font.SysFont('Arial', 15)
    def _init_image_viewer(self):
        if self._image_viewer == 'fbi':
            return self._display_with_fbi
        # else

        # Init pygame display
        display.init()
        # Hide mouse - unnecessary, since it's already
        # done by looper (?)
        # pygame.mouse.set_visible(False)
        # Prepare screen
        size = (display.Info().current_w,
                display.Info().current_h)
        self._screen = display.set_mode(size, FULLSCREEN)
        self.screenW, self.screenH = self._screen.get_size()
        # set screen to black
        self._blank_screen()
        logging.debug('Init configs')
        logging.debug(display.Info())

        return self._display_with_pygame
Example #46
0
def setup():
    """Setup game environment"""
    display.init()
    pygame.font.init()

    pygame.event.set_allowed(None)  # disable all events
    pygame.event.set_allowed((
        pygame.QUIT,
        pygame.VIDEORESIZE,
        pygame.ACTIVEEVENT,
        pygame.KEYDOWN,
    ))  # re-enable some events

    width = 1280
    height = 400

    print("Setting game resolution to {} x {}".format(width, height))
    screen = display.set_mode((width, height), DISPLAY_MODES)
    display.set_caption("tubestrike!")

    screen.fill(BLACK)
    display.flip()
Example #47
0
def main(argv):
    """
    Setup display, bundled schematics. Handle unclean
    shutdowns.
    """

# This should eventually be revived, what is "squash_python"?
#    try:
#        import squash_python
#
#        squash_python.uploader.SquashUploader.headers.pop("Content-encoding", None)
#        squash_python.uploader.SquashUploader.headers.pop("Accept-encoding", None)
#
#        version = release.get_version()
#        client = squash_python.get_client()
#        client.APIKey = "6ea52b17-ac76-4fd8-8db4-2d7303473ca2"
#        client.environment = "unknown"
#        client.host = "http://pixelhost.ezekielelin.com"
#        client.notifyPath = "/mcedit_bugs.php"
#        client.build = version
#        client.timeout = 5
#
# Disabled Crash Reporting Option
#       client.disabled = not config.settings.reportCrashesNew.get()
#       client.disabled = True
#
#       def _reportingChanged(val):
#           client.disabled = not val
#
#       config.settings.reportCrashes.addObserver(client, '_enabled', _reportingChanged)
#       client.reportErrors()
#       client.hook()
#   except (ImportError, UnicodeError) as e:
#       pass

    try:
        display.init()
    except pygame.error:
        os.environ['SDL_VIDEODRIVER'] = 'directx'
        try:
            display.init()
        except pygame.error:
            os.environ['SDL_VIDEODRIVER'] = 'windib'
            display.init()
    pygame.font.init()

    try:
        if not os.path.exists(directories.schematicsDir):
            shutil.copytree(
                os.path.join(directories.getDataDir(), u'stock-schematics'),
                directories.schematicsDir
            )
    except Exception, e:
        logging.warning('Error copying bundled schematics: {0!r}'.format(e))
        try:
            os.mkdir(directories.schematicsDir)
        except Exception, e:
            logging.warning('Error creating schematics folder: {0!r}'.format(e))
Example #48
0
def main(argv):
    """
    Setup display, bundled schematics. Handle unclean
    shutdowns.
    """
    try:
        display.init()
    except pygame.error:
        os.environ['SDL_VIDEODRIVER'] = 'directx'
        try:
            display.init()
        except pygame.error:
            os.environ['SDL_VIDEODRIVER'] = 'windib'
            display.init()
    pygame.font.init()

    try:
        if not os.path.exists(directories.schematicsDir):
            shutil.copytree(
                #os.path.join(directories.getDataDir(), u'stock-schematics'),
                directories.getDataFile('stock-schematics'),
                directories.schematicsDir
            )
    except Exception as e:
        logging.warning('Error copying bundled schematics: {0!r}'.format(e))
        try:
            os.mkdir(directories.schematicsDir)
        except Exception as e:
            logging.warning('Error creating schematics folder: {0!r}'.format(e))

    try:
        ServerJarStorage()
    except Exception as e:
        logging.warning('Error creating server jar storage folder: {0!r}'.format(e))

    try:
        MCEdit.main()
    except Exception as e:
        print "mcedit.main MCEdit exited with errors."
        logging.error("MCEdit version %s", release.get_version())
        display.quit()
        if hasattr(sys, 'frozen') and sys.platform == 'win32':
            logging.exception("%s", e)
            print "Press RETURN or close this window to dismiss."
            raw_input()

        raise

    return 0
Example #49
0
def init():
    """Initialize all inits"""
    _display_.init()
Example #50
0
 def __init__(self):
     display.init()
     self.run()
Example #51
0
def main():
    display.init()
    font.init()
    screen = display.set_mode((640,480))
    run = True
    background = pygame.image.load("images/background.png")
    clock = pygame.time.Clock()
    
    wbackend = wlanbackend()
    fbackend = ftpBackend()
    frmwlan = wlanform(wbackend)
    frmmusic = musicform()
    frmfolders = folderform(frmmusic)

    curConnectedWlan = None
    
    frms = [frmmusic,frmfolders,frmwlan]    
    activefrm = 0

    pygame.key.set_repeat(300,100)

    while run:
        clock.tick(20)
        if curConnectedWlan != wbackend.getConnected():
            curConnectedWlan = wbackend.getConnected()
            overlay(frms[activefrm],InfoType,"Connected to " + str(curConnectedWlan))
            print "Connected to " + str(curConnectedWlan)

        if curConnectedWlan == homeWlan:
            #fbackend.startSync()
            pass

        if fbackend.statusAvailable():
            overlay(frms[activefrm],InfoType,fbackend.getStatus())
            
        #screen.fill((27,103,245))
        screen.blit(background,(0,0))
        frms[activefrm].doFormUpdate()
        frms[activefrm].drawControls(screen)
        display.flip()
        for e in event.get():
            if e.type == pygame.KEYDOWN:
                if e.key == pygame.K_KP_DIVIDE:
                    activefrm -= 1
                    if activefrm < 0:
                        activefrm = len(frms)-1
                elif e.key == pygame.K_KP_MULTIPLY:
                    activefrm += 1
                    if activefrm > len(frms)-1:
                        activefrm = 0
                elif e.key == pygame.K_KP_MINUS:
                    frmmusic.incVolume()
                elif e.key == pygame.K_KP_PLUS:
                    frmmusic.decVolume()
                else:
                    frms[activefrm].handleKeys(e.key)
                
            elif e.type == pygame.QUIT:
                run = False
            elif e.type == pygame.constants.USEREVENT:
                frmmusic.trackFinished()

    fbackend.killSyncBackend()            
Example #52
0
if hasattr(sys, 'pypy_version_info'):
	print ("trying to load pygame_cffi, adding pygame_cffi to sys.path")
	try:
		sys.path.append("pygame_cffi")
		import pygame
	except e:
		print(e)
		sys.path.remove("pygame_cffi")
import pygame
if hasattr(pygame, 'cffi'):
		print("loaded pygame_cffi")
from pygame import display, image, Rect, time
flags = pygame.RESIZABLE#|pygame.DOUBLEBUF


display.init()
from pygame import freetype
freetype.init(cache_size=1024)


import lemon_platform
lemon_platform.SDL = True


import lemon_client, rpcing_frames
import keybindings
import replay

from rpcing_frames import Font, Line

Example #53
0
    def __call__(self, *args, **kwargs):
        from  pygame import display
        from os.path import basename
        import re
        display.init()
        if self.fullscreen:
            resolution = display.list_modes()[0]
            main_surface = display.set_mode(resolution, pygame.FULLSCREEN)
        else:
            resolution = self.resolution
            main_surface = display.set_mode(resolution)
        #main_surface.blit(pygame.image.load('/usr/share/pypicslideshow/img/loadingimages.png'), (100,50))
        pygame.display.update()
        if not len(self.paths) > 0:
            print '\n####  Error: No images found. Exiting!\n'
            exit(1)

        delay = self.delay * 1000
        if not delay > 0:
            print '\n##  Warning: Delay too short. Continuing with delay of 10s...'
            delay = 10000

        pygame.time.set_timer(pygame.USEREVENT + 1, int(delay))

        i = 0
        seq = 1
        img = None
        blitdata = None
        if callable(self.img_callback):
            self.img_callback.__call__(ImgMessage(None,None,None,self.principal))
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    return -1
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        pygame.quit()
                        return 0
                    elif KpMessage.isValidKey(event.key):
                        print '\nKeypress:   ' + event.unicode
                        if callable(self.kp_callback):
                            color = KpMessage.getVote(KpMessage.getKey(event.key)) if KpMessage.isValidKey(event.key) else 'black'
                            self.kp_callback.__call__(KpMessage(event.key,color,seq,img,self.principal))
                            background = KpMessage.getColor(color)
                            if blitdata and background:
                                self._refresh(main_surface, blitdata, background)
                        seq += 1
                elif event.type == pygame.USEREVENT + 1:
                    if i >= len(self.paths):
                        if callable(self.img_callback):
                            self.img_callback.__call__(ImgMessage(None,None,None,self.principal))
                        print '\nFinished.'
                        pygame.quit()
                        return i
                    fn = basename(self.paths[i])
                    img = re.match(r'(.*)[.][^.]+', fn).group(1).replace('.','')
                    print '\nShowing:   ' + self.paths[i]
                    blitdata = self._rationalSizer(pygame.image.load(self.paths[i]), resolution)
                    main_surface = self._refresh(main_surface, blitdata, KpMessage.getColor('black'))
                    if callable(self.img_callback):
                        self.img_callback.__call__(ImgMessage(img,i,fn,self.principal))
                    i += 1
                    seq = 1
            pygame.time.wait(100)