使用python3和pygame包小练游戏玩耍 --屏幕显示

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-28 17:44   34   0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan  3 21:02:38 2018

@author: lisir
"""
# 
import pygame

from sys import exit

background_image_filename = "./tmp/meixi1.jpg"

pygame.init()
SCREEN_SIZE = (1000, 563)
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
background = pygame.image.load(background_image_filename).convert()
 
FullScreen = False
 
while True:
 
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_f:
            FullScreen = not FullScreen
            if FullScreen:
                screen = pygame.display.set_mode(SCREEN_SIZE, FullScreen, 32)
            else:
                screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
    screen.blit(background, (0, 0))
    
    
    pygame.display.update()

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP