飞机大战1
准备工作:导入pygame: 点击pip —>输入pygame 点击确定即可导入。 一:初始化 1.1游戏的初始化和退出: pygame.init() :初始化方法 pygame.quit():退出方法 import pygame pygame . init ( ) print ( "游戏的代码..." ) pygame . quit ( ) 1.2 游戏的坐标系: import pygame hero_rect = pygame . Rect ( 100 , 500 , 120 , 125 ) print ( "英雄的原点 %d %d " % ( hero_rect . x , hero_rect . y ) ) print ( "英雄的尺寸 %d %d" % ( hero_rect . width , hero_rect . height ) ) print ( "%d %d" % hero_rect . size ) 运行结果: pygame 1.9 .6 Hello from the pygame community . https : // www . pygame . org / contribute . html 英雄的原点 100 500 英雄的尺寸 120 125 120 125 1.3 创建游戏的主窗口: import pygame pygame . init