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


Python pygame.mouse方法代码示例

本文整理汇总了Python中pygame.mouse方法的典型用法代码示例。如果您正苦于以下问题:Python pygame.mouse方法的具体用法?Python pygame.mouse怎么用?Python pygame.mouse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame的用法示例。


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

示例1: createGUI

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import mouse [as 别名]
def createGUI( file ):

   # load movie
   movie = pygame.movie.Movie( file )
   width, height = movie.get_size()

   # initialize display window
   screen = pygame.display.set_mode( ( width, height + 100 ) )
   pygame.display.set_caption( "Movie Player" )
   pygame.mouse.set_visible( 1 )

   # play button
   playImageFile = os.path.join( "data", "play.png" )
   playImage = pygame.image.load( playImageFile ).convert()
   playImageSize = playImage.get_rect()
   playImageSize.center = width / 2, height + 50

   # copy play button to screen
   screen.blit( playImage, playImageSize )
   pygame.display.flip()

   # set arqui_recipe surface for movie's video
   movie.set_display( screen )

   return movie, playImageSize 
开发者ID:PythonClassRoom,项目名称:PythonClassBook,代码行数:27,代码来源:fig24_05.py

示例2: main

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import mouse [as 别名]
def main():

   # check command line arguments
   if len( sys.argv ) != 2:
      sys.exit( "Incorrect number of arguments." )
   else:
      file = sys.argv[ 1 ]
      
   # initialize pygame
   pygame.init()

   # initialize GUI
   movie, playImageSize = createGUI( file )

   # wait until player wants to close program
   while 1:
      event = pygame.event.wait()

      # close window
      if event.type == QUIT or \
         ( event.type == KEYDOWN and event.key == K_ESCAPE ):
         break

      # click play button and play movie
      pressed = pygame.mouse.get_pressed()[ 0 ]
      position = pygame.mouse.get_pos()

      # button pressed
      if pressed:

         if playImageSize.collidepoint( position ):
            movie.play() 
开发者ID:PythonClassRoom,项目名称:PythonClassBook,代码行数:34,代码来源:fig24_05.py

示例3: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import mouse [as 别名]
def __init__(self, pos):
        self.max_speed = SETTINGS.player_speed
        self.speed = 0
        self.angle = SETTINGS.player_angle
        self.health = SETTINGS.player_health

        self.real_x = pos[0]
        self.real_y = pos[1]

        self.color = SETTINGS.BLUE
        self.sprite = pygame.Surface([SETTINGS.tile_size / 12, SETTINGS.tile_size / 12])
        self.sprite.fill(self.color)
        self.rect = self.sprite.get_rect()
        self.rect.x = self.real_x
        self.rect.y = self.real_y
        SETTINGS.player_rect = self.rect
        self.last_pos_tile = None

        self.mouse = pygame.mouse
        self.sensitivity = SETTINGS.sensitivity
        self.gun = 0
        self.gunsprites_aim = []
        self.gunsprites_shoot = []

        SETTINGS.player = self
        self.collide_list = SETTINGS.all_solid_tiles + SETTINGS.npc_list
        self.update_collide_list = False
        self.solid = True
        self.dead = False
        self.last_call = 0
        self.type = 'player'
        self.hurt_sound = pygame.mixer.Sound(os.path.join('sounds', 'other', 'damage.ogg'))
        self.change_level = pygame.mixer.Sound(os.path.join('sounds', 'other', 'next_level.ogg'))

        self.current_level = SETTINGS.current_level

        #input variables
        self.mouse2 = 0
        self.inventory = 0
        self.esc_pressed = False
        self.dont_open_menu = False 
开发者ID:MaxwellSalmon,项目名称:DUGA,代码行数:43,代码来源:PLAYER.py

示例4: update

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import mouse [as 别名]
def update(self, time):
        if self._can_focus:
            self._update_select_text(time)
            # Change cursor when mouse not held down
            if not pygame.mouse.get_pressed()[0]:
                if not self._over and \
                  self.rect_abs.collidepoint(pygame.mouse.get_pos()):
                    self._over = True
                    self._set_cursor(*self._cursor)
                elif self._over and \
                  not self.rect_abs.collidepoint(pygame.mouse.get_pos()):
                    self._over = False
                    self._remove_cursor()
            if self.has_focus():
                self._switch() 
开发者ID:furas,项目名称:python-examples,代码行数:17,代码来源:label.py

示例5: initPygame

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import mouse [as 别名]
def initPygame(self):
		pygame.init()
		self.screen = pygame.display.set_mode((self.w, self.h))
		pygame.mouse.set_visible(False)
		self.clock = pygame.time.Clock() 
开发者ID:basti2342,项目名称:gif-music-visualizer,代码行数:7,代码来源:visualizer.py


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