首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“从游戏社区来的你好”

“从游戏社区来的你好”
EN

Stack Overflow用户
提问于 2022-04-16 01:12:39
回答 1查看 336关注 0票数 -3

当我执行下面的代码时,它不再是一个错误,而是说“https://www.pygame.org/contribute.html"来自吡游社区的你好。如果它只是包含错误,这样我就可以自己修复它,而不必将代码放在堆栈溢出中(出于隐私原因)。”

下面是代码:

代码语言:javascript
复制
# import the pygame module, so you can use it
import pygame

# define a main function
def main():
    # initialize the pygame module
    pygame.init()
    # load and set the logo
    logo = pygame.image.load("logo32x32.png")
    pygame.display.set_icon(logo)
    pygame.display.set_caption("minimal program")

    # create a surface on screen that has the size of 240 x 180
    screen = pygame.display.set_mode((240, 180))

    # define a variable to control the main loop
    running = True

    # main loop
    while running:
        # event handling, gets all event from the eventqueue
        for event in pygame.event.get():
            # only do something if the event is of type QUIT
            if event.type == pygame.QUIT:
                # change the value to False, to exit the main loop
                running = False

        # draw a green line from (0,0) to (100,100)
        pygame.draw.line(screen, (0,255,0), (0,0), (100,100))

        # draw a green line from (0,100) to (100,0)
        pygame.draw.line(screen, (0,255,0), (0,100), (100,0))

        # draw a rectangle outline
        pygame.draw.rect(screen, (0,255,0), (60,60,100,50), 1)

        # draw a filled in rectangle
        pygame.draw.rect(screen, (0,255,0), (60,120,100,50))

        # draw a circle
        pygame.draw.circle(screen, (0,255,0), (120,60), 20, 0)

        # draw a circle outline
        pygame.draw.circle(screen, (0,255,0), (120,60), 20, 1)

        # draw a polygon
        pygame.draw.polygon(screen, (0,255,0), ((140,60),(160,80),(160,100),(140,120),(120,100),(120,80)), 0)

        # draw a filled in poly
        pygame.draw.polygon(screen, (0,255,0), ((140,60),(160,80),(160,100),(140,120),(120,100),(120,80)), 1)

        # draw a text
        font = pygame.font.Font(None, 36)
        text = font.render("Hello There", 1, (10, 10, 10))
        textpos = text.get_rect()
        textpos.centerx = screen.get_rect().centerx
        screen.blit(text, textpos)

        # update the screen
        pygame.display.flip()

    # quit pygame properly to clean up resources
    pygame.quit()

# end of the code
EN

回答 1

Stack Overflow用户

发布于 2022-04-23 19:36:29

这不是个错误。这一行是在你输入游戏时打印出来的。您的任何代码都不会产生错误,因为它们都没有被调用。定义了main函数之后,确保调用main()。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71890298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档