Beispiel #1
0
def main():
    try:
        if '--profile' in sys.argv:
            profile('start_game()')
        else:
            start_game()
    finally:
        display.quit()
Beispiel #2
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
Beispiel #3
0
def finalize():
   print 1
   PDI.quit()
   print 2
   PX.quit()
   print 3
   PG.quit()
   print 4
   SYS.exit()
   print 5
Beispiel #4
0
 def exec_(self):
     self.naubino.play()
     okay = True
     clock = pygame.time.Clock()
     while okay:
         for ev in event.get():
             if False: pass
             elif ev.type == constants.QUIT:
                 okay = False
             elif ev.type == constants.KEYDOWN and ev.key == constants.K_ESCAPE:
                 okay = False
         dt = clock.tick(60) / 1000.0
         self.step(dt)
     display.quit()
Beispiel #5
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
Beispiel #6
0
def quit():
    """Quits all instances"""
    _display_.quit()
Beispiel #7
0
	def __del__(self):
		pgdisplay.quit()
Beispiel #8
0
 def kill(self):
     """Close the screen."""
     display.quit()
def finalize():
    PDI.quit()
    PX.quit()
    PG.quit()
    SYS.exit()
Beispiel #10
0
            for s in sys.path
    ]:
        sys.path.append(
            directories.filtersDir.encode(sys.getfilesystemencoding()))

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

    try:
        MCEdit.main()
    except Exception as e:
        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


def getSelectedMinecraftVersion():
    profile = directories.getMinecraftProfileJSON()[
        directories.getSelectedProfile()]
    if 'lastVersionId' in profile:
        return profile['lastVersionId']
Beispiel #11
0
    def test_quit__multiple(self):
        """Ensures the module is not initialized after multiple quit calls."""
        display.quit()
        display.quit()

        self.assertFalse(display.get_init())
Beispiel #12
0
 def _quit_display(self) -> None:
     display.quit()
Beispiel #13
0
 def destroy(self):
     # Destroy the current screen
     display.quit()
Beispiel #14
0
 def destroy():
     """
     Destroys the current screen object.
     """
     display.quit()
Beispiel #15
0
def dwarfgraph_loop(limit_mass=None):
    fondo = display.set_mode((ANCHO, ALTO), SCALED)
    fondo.fill(COLOR_BOX)

    fuente2 = font.SysFont('Verdana', 13, bold=True)

    render = fuente2.render('Mass', True, COLOR_TEXTO, COLOR_BOX)
    render = transform.rotate(render, -90)
    render_rect = render.get_rect(right=ANCHO - 53, centery=ALTO / 2)
    fondo.blit(render, render_rect)

    render = fuente2.render('Radius', True, COLOR_TEXTO, COLOR_BOX)
    render_rect = render.get_rect(x=3, y=3)
    fondo.blit(render, render_rect)

    text_mass = 'Mass: N/A'
    text_radius = 'Radius: N/A'
    text_density = 'Density: N/A'

    done = False
    data = {}

    lineas = WidgetGroup()
    linea_h = Linea(bg_rect, bg_rect.x, bg_rect.centery, bg_rect.w, 1, lineas)
    linea_v = Linea(bg_rect, bg_rect.centerx, bg_rect.y, 1, bg_rect.h, lineas)
    punto = Punto(bg_rect, bg_rect.centerx, bg_rect.centery, lineas)

    lim_img, lim_rect = None, None
    if limit_mass is not None:
        lim_y = find_and_interpolate(limit_mass, mass_keys, yes)
        lim_rect = Rect(54, lim_y + 26, bg_rect.w,
                        bg_rect.h - lim_y - 26 + bg_rect.y)
        lim_img = Surface(lim_rect.size)
        lim_img.set_alpha(150)

    move_x, move_y = True, True
    while not done:
        for e in event.get(
            [KEYDOWN, QUIT, MOUSEMOTION, MOUSEBUTTONDOWN, KEYUP]):
            if (e.type == KEYDOWN and e.key == K_ESCAPE) or e.type == QUIT:
                quit()
                exit()

            elif e.type == MOUSEMOTION:
                x, y = e.pos

                if move_y:
                    linea_h.move_y(y)
                    punto.move_y(y)

                if move_x:
                    linea_v.move_x(x)
                    punto.move_x(x)

                dx, dy = punto.rect.center
                if bg_rect.collidepoint(dx, dy):
                    mass = round(
                        find_and_interpolate(linea_h.rect.y - 26, yes,
                                             mass_keys), 5)
                    radius = round(
                        find_and_interpolate(linea_v.rect.x, exes,
                                             radius_keys), 3)

                    data.update({
                        'mass': mass,
                        'radius': radius,
                        'clase': 'Dwarf Planet',
                        'albedo': 40
                    })
                    d = density(mass, radius)
                    text_mass = 'Mass: {}'.format(mass)
                    text_radius = 'Radius: {}'.format(radius)
                    text_density = 'Density: {}'.format(d)
                    color = bg.get_at((dx - 54, dy - 24))
                    composition = {}
                    s, i, r = 0, 0, 0
                    if tuple(color) == (63, 223, 0, 255):
                        i = 100
                    elif tuple(color) == (31, 255, 0,
                                          255):  # 10% silicates, 90% water ice
                        i = round(roll(60, 90), 2)
                        s = round(100 - i, 2)
                    elif tuple(color) == (95, 191, 0,
                                          255):  # 60% silicates, 40% water ice
                        s = round(roll(50, 60), 2)
                        i = round(100 - s, 2)
                    elif tuple(color) == (127, 159, 0,
                                          255):  # 90% silicates, 10% water ice
                        s = round(roll(60, 90), 2)
                        i = round(100 - s, 2)
                    elif tuple(color) == (159, 127, 0,
                                          255):  # 90% silicates, 10% iron
                        s = round(roll(60, 90), 2)
                        r = round(100 - s, 2)
                    elif tuple(color) == (191, 95, 0,
                                          255):  # 60% silicates, 40% iron
                        s = round(roll(50, 60), 2)
                        r = round(100 - s, 2)
                    elif tuple(color) == (223, 63, 0,
                                          255):  # 10% silicates, 90% iron
                        r = round(roll(60, 90), 2)
                        s = round(100 - r, 2)
                    elif tuple(color) == (255, 31, 0, 255):
                        r = 100

                    if s:
                        composition['silicates'] = s
                    if i:
                        composition['water ice'] = i
                    if r:
                        composition['iron'] = r

                    data['composition'] = composition
                else:
                    text_mass = 'Mass: N/A'
                    text_radius = 'Radius: N/A'
                    text_density = 'Density: N/A'

            elif e.type == MOUSEBUTTONDOWN:
                if e.button == 1:
                    done = True

            elif e.type == KEYDOWN:
                if e.key == K_SPACE:
                    done = True

                elif e.key == K_LSHIFT:
                    move_x = False

                elif e.key == K_LCTRL:
                    move_y = False

            elif e.type == KEYUP:
                if e.key == K_LSHIFT:
                    move_x = True

                elif e.key == K_LCTRL:
                    move_y = True

        render_mass = fuente.render(text_mass, True, COLOR_TEXTO, COLOR_BOX)
        render_radius = fuente.render(text_radius, True, COLOR_TEXTO,
                                      COLOR_BOX)
        render_density = fuente.render(text_density, True, COLOR_TEXTO,
                                       COLOR_BOX)

        fondo.fill(COLOR_BOX)
        fondo.blit(render_mass, (3, ALTO - 20))
        fondo.blit(render_radius, (150, ALTO - 20))
        fondo.blit(render_density, (300, ALTO - 20))
        fondo.blit(bg, bg_rect)
        if limit_mass is not None:
            fondo.blit(lim_img, lim_rect)
        numbers.draw(fondo)
        lineas.update()
        lineas.draw(fondo)
        display.update()

    display.quit()
    return data
Beispiel #16
0
 def tearDown(self):
     display.quit()
Beispiel #17
0
    def test_quit(self):
        """Ensures the module is not initialized after quit called."""
        display.quit()

        self.assertFalse(display.get_init())
Beispiel #18
0
 def destroy():
     """
     Destroys the current screen object.
     """
     display.quit()
Beispiel #19
0
def clean_screen():
    from pygame.display import quit
    quit()
    from pygame.font import quit
    quit()
Beispiel #20
0
        try:
            os.mkdir(directories.schematicsDir)
        except Exception, e:
            logging.warning('Error creating schematics folder: {0!r}'.format(e))

    try:
        ServerJarStorage()
    except Exception, 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


def getSelectedMinecraftVersion():
    profile = directories.getMinecraftProfileJSON()[directories.getSelectedProfile()]
    if 'lastVersionId' in profile:
        return profile['lastVersionId']
    else:
Beispiel #21
0
 def close(self):
     display.quit()