pygame简介屏幕的设计_游戏模版框架_风火轮少儿编程.py

"""pygame简介屏幕的设计_游戏模版框架_风火轮少儿编程.py
"""
 
import pygame
 
# 定义颜色常量
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
 
pygame.init()
 
# 设置宽度和高度,然后新建屏幕
size = [700, 500]
screen = pygame.display.set_mode(size)
 
pygame.display.set_caption("pygame简介屏幕的设计_游戏模版框架_风火轮少儿编程")
 
# 此变量用来当用户单击了窗口的关闭按扭时,它的值会变成True,从而退出while循环
done = False
 
# 用来设置fps的时钟对象
clock = pygame.time.Clock()
 
# 矩形的起始坐标
rect_x = 50
rect_y = 50
 
# 矩形的速度,也代表着方向
rect_change_x = 5
rect_change_y = 5
 
# 建立字体对象
font = pygame.font.Font("msyh.ttf", 36) # 注意字体,这里是微软雅黑
 
display_instructions = True
instruction_page = 1
 
# --------介绍页循环-----------
while not done and display_instructions:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        if event.type == pygame.MOUSEBUTTONDOWN:
            instruction_page += 1
            if instruction_page == 3:
                display_instructions = False
 
    # 设置屏幕背景颜色
    screen.fill(BLACK)
 
    if instruction_page == 1:
        
        # 游戏简介页,游戏的开始, 
        text = font.render("欢迎来到这个游戏.", True, WHITE)
        screen.blit(text, [10, 10])
 
        text = font.render("这里是第一页,单击继续", True, WHITE)
        screen.blit(text, [10, 60])
        
        text = font.render("也可以换成一张漂亮的海报!", True, WHITE)
        screen.blit(text, [10, 110])

You must log in to read the rest of this article. Please log in or register as a user.