当前位置: 首页>>代码示例>>Python>>正文


Python mouse.set_visible函数代码示例

本文整理汇总了Python中pygame.mouse.set_visible函数的典型用法代码示例。如果您正苦于以下问题:Python set_visible函数的具体用法?Python set_visible怎么用?Python set_visible使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_visible函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

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
开发者ID:sfavors3,项目名称:MindMixer,代码行数:57,代码来源:mindmixer.py

示例2: handle

    def handle(self, e):
        if e.type == KEYDOWN:
            pressed = key.get_pressed()
            shifted = pressed[K_LSHIFT] or pressed[K_RSHIFT]
            scroll = 10 if shifted else 1
            
            if e.key == K_UP:
                self._scroll(1, -scroll)
                return True
                
            elif e.key == K_DOWN:
                self._scroll(1, scroll)
                return True
                
            elif e.key == K_LEFT:
                self._scroll(0, -scroll)
                return True
                
            elif e.key == K_RIGHT:
                self._scroll(0, scroll)
                return True
                    
            elif e.unicode == '>':
                self._zscroll(-1)
                return True
                
            elif e.unicode == '<':
                self._zscroll(1)
                return True

            elif e.key == K_TAB:
                self._select(self.cursor)
                mouse.set_visible(False)
                return True

        elif (e.type == MOUSEBUTTONDOWN and
              self.background and
              self.background.get_rect().collidepoint(e.pos) and
              e.button == 1):
            self._select(self._absolutetile(mouse.get_pos()))
            return True
        
        elif (e.type == MOUSEBUTTONUP and
              self.background and
              self.background.get_rect().collidepoint(e.pos) and
              e.button == 1):
            self._dragging = False
            return True

        elif (e.type == MOUSEMOTION and self.background and
            self.background.get_rect().collidepoint(e.pos) and
            1 in e.buttons):
            self._expandselection(self._absolutetile(mouse.get_pos()))
            self._dragging = True
            
        return False
开发者ID:tps12,项目名称:Dorftris,代码行数:56,代码来源:playfield.py

示例3: handle

    def handle(self, e):
        if e.type == MOUSEMOTION and e.rel != self._ignore:
            mouse.set_visible(True)
            self._ignore = None
        
        if self._playfield.handle(e):
            return True

        if 'pos' in e.dict:
            e.dict['pos'] = (e.pos[0] - self._fieldwidth, e.pos[1])
        return self._info.handle(e)
开发者ID:tps12,项目名称:Dorftris,代码行数:11,代码来源:screen.py

示例4: create_game

    def create_game(self):
        """Initializes the game."""

        os.environ['SDL_VIDEO_CENTERED'] = '1'
        self.screen = display.set_mode(RESOLUTION, False, 32)
        self.scene = Scene(self.screen)
        self.events = EventManager(self.scene)
        self.clock = time.Clock()
        display.set_caption("%s %s" % (NAME, VERSION))
        mouse.set_visible(False)
        if FULLSCREEN:
            toggle_fullscreen()
开发者ID:derrida,项目名称:shmuppy,代码行数:12,代码来源:game.py

示例5: setVisible

    def setVisible(self,visible):
        """Sets the visibility of the mouse to 1 or 0

        NB when the mouse is not visible its absolute position is held
        at (0,0) to prevent it from going off the screen and getting lost!
        You can still use getRel() in that case.
        """
        if usePygame: mouse.set_visible(visible)
        else:
            if self.win: #use default window if we don't have one
                w = self.win.winHandle
            else:
                w=pyglet.window.get_platform().get_default_display().get_windows()[0]
            w.set_mouse_visible(visible)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:14,代码来源:event.py

示例6: set_exclusive_mouse

 def set_exclusive_mouse(self, exclusive):
     
     if not exclusive == self._exclusive_mouse:
         self._exclusive_mouse = exclusive
         
         if self._exclusive_mouse:
             mouse.set_visible(False)
             pygame.event.set_grab(True)
             
             self._ex_mouse_x, self._ex_mouse_y = pygame.mouse.get_pos()
         else:
             # Show the cursor
             mouse.set_visible(True)
             pygame.event.set_grab(False)
             pygame.mouse.set_pos(self._ex_mouse_x, self._ex_mouse_y)
开发者ID:freneticmonkey,项目名称:Epsilon,代码行数:15,代码来源:pygameframework.py

示例7: _on_keyboard_down

    def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
        """ with this is possible to control to show/hidden the faces """
        if keycode[1] == 's' or keycode[1] == 'S':
            self.hide_faces()
            self.show_faces()
            self.navcolor = [1,1,1,1]
            Clock.unschedule(self._next_function)
            mouse.set_visible(True)
        if keycode[1] == 'h' or keycode[1] == 'H':
            self.hide_faces()
            self.navcolor = [1,1,1,0]
            Clock.schedule_once(self._next_function,settings.SECONDS_PER_IMAGE)
            mouse.set_visible(False)
        if keycode[1] == 'f' or keycode[1] == 'F':
            Window.toggle_fullscreen()

        return True
开发者ID:drtimcouper,项目名称:gamex,代码行数:17,代码来源:gamex.py

示例8: _updatecursorsprite

 def _updatecursorsprite(self):
     self.cursorsprite.location = self.cursor
     self.cursorsprite.visible = not mouse.set_visible(-1)
     
     if self.cursorsprite.location:
         if not self.sprites.has(self.cursorsprite):
             self.sprites.add(self.cursorsprite)
     else:
         if self.sprites.has(self.cursorsprite):
             self.sprites.remove(self.cursorsprite)
开发者ID:tps12,项目名称:Dorftris,代码行数:10,代码来源:playfield.py

示例9: __init__

    def __init__(self, fps=FRAMES_PER_SECOND):
        game.Game.__init__(self, fps)
        mouse.set_visible(False)

        # Create the ship and place it in the center of the screen:
        center = shapes.Point(self.width / 2, self.height / 2)
        self.ship = shapes.Ship(center, SHIP_INITIAL_ROTATION, SHIP_COLOR)

        # Create bullet and upgrade lists:
        self.bullets = []
        self.upgrades = []

        # Create asteroids and background stars:
        self.asteroids = []
        self.spawn_asteroids()
        self.stars = []
        while len(self.stars) < (self.width * STAR_DENSITY):
            self.stars.append(shapes.Star(self.get_random_point()))

        # Initialize mixer and start looping background music:
        mixer.init()
        mixer.music.load(BACKGROUND_MUSIC)
        mixer.music.play(-1)
开发者ID:theDrake,项目名称:asteroids-py,代码行数:23,代码来源:asteroids.py

示例10: _scroll

    def _scroll(self, axis, amount):
        size = self.zoom.width if axis == 0 else self.zoom.height

        pos, tile = self._mouse()
        x0, y0 = pos

        while (tile is not None and
               ((amount < 0 and
                 tile[axis] + self.offset[axis] >
                 self.game.dimensions[axis] - self.dimensions[axis]/2) or
                (amount > 0 and
                 tile[axis] + self.offset[axis] <
                 self.dimensions[axis]/2))):
            pos, tile = self._mouse(tuple([pos[i] + (size * amount/abs(amount)
                                                     if i == axis else 0)
                                           for i in range(2)]))
            amount -= amount/abs(amount)

        dest, remainder = self._clamp(
            self.offset[axis] + amount,
            (0, self.game.dimensions[axis] - self.dimensions[axis]))
        
        self.offset = tuple([dest if i == axis else self.offset[i]
                             for i in range(2)])

        while tile is not None and ((remainder < 0 and 0 < tile[axis]) or
               (remainder > 0 and tile[axis] < self.dimensions[axis]-1)):
            pos, tile = self._mouse(tuple([pos[i] +
                                           (size * remainder/abs(remainder)
                                            if i == axis else 0)
                                           for i in range(2)]))
            remainder -= remainder/abs(remainder)

        self.background = None
        mouse.set_visible(False)
        self._ignoremotion((pos[0] - x0, pos[1] - y0))
开发者ID:tps12,项目名称:Dorftris,代码行数:36,代码来源:playfield.py

示例11: set_cursor

 def set_cursor(self, cursor):
     """cursor can be either None, image name, Image, Sprite or HWCursor)"""
     if cursor is None:
         mouse.set_visible(False)
         self._sprite = None
         self._cursor = None
     elif isinstance(cursor, HWCursor):
         self._cursor = cursor
         self._sprite = None
         mouse.set_cursor(*cursor._data)
         mouse.set_visible(True)
     elif isinstance(cursor, Sprite):
         mouse.set_visible(False)
         self._sprite = cursor
         self._cursor = self.sprite
     else:
         s = Sprite(cursor)
         mouse.set_visible(False)
         self._sprite = s
         self._cursor = s
开发者ID:bcorfman,项目名称:opioid2d,代码行数:20,代码来源:Mouse.py

示例12: show

 def show(self):
     set_visible(True)
开发者ID:gregr,项目名称:old-and-miscellaneous,代码行数:2,代码来源:mouse.py

示例13: go

def go():
    
                     
    # START
    
    # Fairly obvious, initialize the pygame library
    pygame.init()
    
    # Create the world in which all physical things reside. It is our coordinate system and universe.
    world = World(vector((20.0, 20.0, 2000.0)), vector((-10.0, 0.0, 10.0)))
    
    # Create startup cameras and make the world visible to them
    eyecam = Camera()
    eyecam.registerObject(world)
    scopecam = Camera()
    scopecam.registerObject(world)
    
    # Setup the program window (just a special case of a View)
    screen = Screen(eyecam, vector((1000,800,0)), -1.0)
    screen.display = pygame.display.set_mode((1000, 800))
    
    # Setup the display surfaces to be drawn to screen and list them
    main_dim = vector((1000,800,0.0))
    scope_dim = vector((240,240,0.0))
    mainview = View(eyecam, main_dim, zero_vector, 1.0)
    scopeview = Scope(scopecam, scope_dim, (main_dim - scope_dim) / 2.0, 4.0)
    views = [ mainview, scopeview ]
    
    # Hide the cursor
    mouse.set_visible(False)
    
    # Let's set up some useful variables
    now = pygame.time.get_ticks()   # The current program time
    shot_fired = False              #
    chase_bullet = False
    hide_scope = True
    lock_mouse = False
    power = 100.0
    #mainview.reposition(eyecam)
    scopeview.setPower(power)
    timescale = 1.0
    tot_mag = 0.0
    tot_dur = 0.0
    frames = 0
    
    if lock_mouse:
        mouse.set_pos((scope_dim / 2.0).xy())
    
    while 1:
        
    
    
        last_t = now
        now = pygame.time.get_ticks()
        t_length = float(now - last_t)
        
        if world.has_hit:
            shot_end = now
            #break
        
        if world.bullet.position.z() > world.target.position.z() + 1000.0:
            #world.bullet.position = vector((world.bullet.position.x(), world.bullet.position.y(), world.target.position.z() - 0.01))
            shot_end = now
            break
            #pass
                
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.dict['button'] == 4:
                    power += 1.0
                if event.dict['button'] == 5:
                    power -= 1.0
                power = scopeview.setPower(power)
                print power
            
            if event.type == pygame.QUIT:
                sys.exit()
                
        
        
        sx, sy = (0.5 * mainview.dimensions).xy()
        if lock_mouse:
            mx, my = mouse.get_rel()
            mouse.set_pos(sx, sy)
            r = (1.0 / (10000 * power))* (vector((sx - mx, sy - my, 0)))
            scopecam.rotation += r
            eyecam.rotation += r
        else:
            mx, my = mouse.get_pos()
            r = (1.0 / (1000 * power))* (vector((sx - mx, sy - my,  0)))
            scopecam.rotation = r
            eyecam.rotation = r
        
        world.bullet.rotation = scopecam.rotation
        scopeview.reposition(scopeview.camera)
        mainview.reposition(mainview.camera)
          
        b1, b2, b3 = mouse.get_pressed()
        if b1 and not shot_fired:
            shot_fired = True
#.........这里部分代码省略.........
开发者ID:jc2brown,项目名称:Plink,代码行数:101,代码来源:plink.py

示例14: hide

 def hide(self):
     set_visible(False)
开发者ID:gregr,项目名称:old-and-miscellaneous,代码行数:2,代码来源:mouse.py

示例15: int

start_cols = SIZE[0]/100*1.625 # start position for cols
step_rows = SIZE[0]/100*5.3125 # rows shift
step_cols = SIZE[0]/100*4.6875 # columns shift
pos = [start_rows_uneven, start_cols]

rows = int(SIZE[1]/((SIZE[0]/100*3.125)*1.5))+1 # number of rows
cols = int(SIZE[0]/((SIZE[0]/100*3.125)*1.5))+1 # number of columns

# list x coords for lable words
lable_x_positions = (('PRESS', int(SIZE[0] / 100 * 34.6875)),
                     ('ESC', int(SIZE[0] / 100 * 40.625)),
                    ('FOR', int(SIZE[0] / 100 * 40.625)),
                    ('EXIT', int(SIZE[0] / 100 * 38.75)))
lable_start_y = int(SIZE[0] / 100 * 9.375)

mouse.set_visible(False) # set invisible for mouse cursor

while 1:
    for e in event.get():
        if e.type == KEYDOWN:
            if e.key == K_ESCAPE:
                sys.exit()

    screen.fill((40, 40, 40))

    # draw lables
    for lable in lable_x_positions:
        screen.blit(ff.render(lable[0], 1, (55, 55, 55)), (lable[1], lable_start_y*(lable_x_positions.index(lable)+1)))

    # rotation
    if angle > 1.04 and angle < 1.05:
开发者ID:LoganStalker,项目名称:screensavers,代码行数:31,代码来源:honeycomb.py


注:本文中的pygame.mouse.set_visible函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。