本文整理汇总了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
示例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()
示例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
示例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()
示例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()