基础DAY14-飞机大战-创建游戏主窗口

python -m pygame.examples.aliens

import pygame
pygame.init()
# 编写邮箱代码
print("游戏代码")
pygame.quit()
初始化和退出

import pygame
# 定义hero_rect矩形描述英雄的位置和大小
hero_rect = pygame.Rect(100, 500, 120, 125)
# 输出英雄的坐标原点(x 和 y)
print("英雄的原点%d %d" % (hero_rect.x, hero_rect.y))
# 输出英雄的尺寸(宽度和高度)
print(hero_rect.size)
print("英雄的尺寸%d %d" % hero_rect.size)
print("英雄的尺寸%d %d" % (hero_rect.width, hero_rect.height))
size属性是一个元组,返回第一个值是矩形宽,第二个值是高

import pygame
pygame.init()
# 创建游戏窗口
screen = pygame.display.set_mode((480, 700))
pygame.display.update()
while True:
    pass
pygame.quit()
空窗口
原文地址:https://www.cnblogs.com/joycezhou/p/11420930.html