import pygame pygame.init() window = pygame.display.set_mode((800, 600)) # 调整窗口大小 window = pygame.display.set_mode((1024, 768)) # 游戏主循环 running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() 在这个示...
screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), RESIZABLE) for event in pygame.event.get(KEYDOWN): if event.key == K_F11: if not isfullscreen: isfullscreen = True SIZE = WINDOWWIDTH, WINDOWHEIGHT = pygame.display.list_modes()[0] screen = pygame.display.set_mode(SIZE, F...
screen = pygame.display.set_mode(size) # 设置窗口标题 pygame.display.set_caption("闲得发慌") # 加载图片 people = pygame.image.load("p.gif") # 获得图像位置矩形 position = people.get_rect() # 图片方向 l_head = people r_head = pygame.transform.flip(people,True,False) while True: for...
pygame.display.get_surface() -> Surface # 获取当前窗口的 Surface, 即 set_mode() 返回的对象 pygame.display.get_num_displays() -> int # 返回显示器的数量 pygame.display.get_window_size() -> tuple # 返回窗口或屏幕的大小, 即 set_mode() 返回的 Surface 大小, 如果使用了 pygame.SCALED, 可...
screen = pygame.display.set_mode(IMG_ROAD.get_size()) h=IMG_ROAD.get_width()//2 v=IMG_ROAD.get_height() - (IMG_PLAYER.get_height()//2) player = pygame.sprite.Sprite() player.image = IMG_PLAYER player.surf = pygame.Surface(IMG_PLAYER.get_size()) ...
screen = pygame.display.set_mode(IMG_ROAD.get_size()) h=IMG_ROAD.get_width()//2 v=IMG_ROAD.get_height() - (IMG_PLAYER.get_height()//2) player = pygame.sprite.Sprite() player.image = IMG_PLAYER player.surf = pygame.Surface(IMG_PLAYER.get_size()) ...
screen = pygame.display.set_mode(IMG_ROAD.get_size()) h=IMG_ROAD.get_width()//2 v=IMG_ROAD.get_height() - (IMG_PLAYER.get_height()//2) player = pygame.sprite.Sprite() player.image = IMG_PLAYER player.surf = pygame.Surface(IMG_PLAYER.get_size()) ...
self.rect.x= self.x#移动球图形self.rect.y =self.yif(self.rect.left <= 0orself.rect.right >= screen.get_width()):#到达左右边界self.dx *= -1#水平速度变号elif(self.rect.top <= 5orself.rect.bottom >= screen.get_height()-5):#到达上下边界self.dy *= -1#垂直速度变号pygame.init...
pygame.display.set_caption("鼠标移动事件") background=pygame.Surface(screen.get_size()) background=background.convert() background.fill((255,255,255)) ball= pygame.Surface((30,30))#建立球的矩形背景绘图区ball.fill((255,255,255))#矩形区域背景为白色pygame.draw.circle(ball, (0,0,255), ...
for event in pygame.event.get(): if event.type in (QUIT,KEYDOWN): sys.exit() #设置窗口的背景颜色 screen.fill(blue) #将字体对象绑定到窗口上,并且设置文字显示的位置 screen.blit(textImage, (100, 100)) #pygame将内容更新出来 pygame.display.update() ...