猫史档案馆


【Python作品分享】8-太空狙击(一)-工程包【作品秀】

用户:袁浚淇袁浚淇查看:2 回复:1 评论:2 创建时间:2021-12-19T17:00:54


【作品展示】

center_image

 

【作品介绍】

eeeehny

 

【作品源代码】

import pygame
from pygame.locals import*

pygame.init()  # 初始化bygame库

WIDTH = 400
HEIGHT = 600

class Plane:
    def __init__(self):
        self.image = pygame.image.load('img_plane.png')
        self.rect = self.image.get_rect()
        self.rect.centerx = WIDTH/2
        self.rect.bottom = HEIGHT - 10

    def update(self):
        pass


#shezhipygame窗口,设置窗口大小
screen = pygame.display.set_mode((WIDTH, HEIGHT))
plane = Plane()
bg = pygame.image.load('img_bg.jpg')

running = True
while running:
    screen.blit(bg, (0, 0))
    screen.blit(plane.image, plane.rect)
    pygame.display.flip()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                running = False
#退出
pygame.quit()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
全宇宙最酸的柠檬全宇宙最酸的柠檬

这个贴梓会被我用来测试(bushi

点赞0


评论