查看: 240|回复: 0

pygame 简单程序 案例一 移动的字体

[复制链接]

237

主题

314

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
21620
发表于 2022-7-11 23:19:42 | 显示全部楼层 |阅读模式
[Python] 纯文本查看 复制代码
import pygame
# 导入游戏环境
from game import *
import sys
from pygame.color import THECOLORS
x = 0
white = 255, 255, 0
blue = 0, 0, 200
# 初始化
pygame.init()  # pygame 初始化
screen = pygame.display.set_mode((800, 600))  # 创建屏幕
clock = pygame.time.Clock()  # 生成游戏时钟
 
myfont = pygame.font.Font(None, 60)
textImage = myfont.render("Hello GSTEM", True, white)
 
 
# 主循环
while True:
    # 事件检测
    for event in pygame.event.get():
        # 退出游戏
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    screen.fill(blue)
    if x < 500:
        x = x+0.1
    else:
        x = 0
    screen.blit(textImage, (x, 20))
    pygame.display.update()

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表