猫史档案馆


【Python作品分享】pygame基本结构改版【作品秀】

用户:淼霖稞淼霖稞查看:0 回复:0 评论:0 创建时间:2020-11-29T11:15:44


【作品展示】

center_image

 

【作品介绍】

没啥

 

【作品源代码】

import pygame
import sys

def run_game():
    pygame.init()

    pygame.display.set_caption("测试")
    SIZE = (580, 280)
    BG_COLOUR = (0, 0, 0)
    LINE_COLOUR = (255, 255, 255)

    window = pygame.display.set_mode(SIZE)
    clock = pygame.time.Clock()
    x=0
    y=0
    x_age = pygame.image.load("x.png")

    class xxx:
        def __init__(self,x,y):
            self.x = x
            self.y = y
        def xy(self):
            window.blit(x_age,(self.x,self.y))

    while True:
        time_passed = clock.tick(30)
        #载入图片三步骤:1.x_age = pygame.image.load("x.png")加载
        #2.window.blit(x_age,(0,0))显示
        #3.pygame.display.flip()刷新
        pygame.display.flip()
        xxx(0,0).xy()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit_game()


def exit_game():
    sys.exit()

if __name__ == "__main__":
    run_game()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页