使用pygame.display继承错误

发布于 2025-01-28 12:12:02 字数 647 浏览 2 评论 0原文

import pygame.display.Display as display


class MainDisplay(display):

    def __init__(self):
        super.__init__()

        # creating display
        X = 500
        Y = 1000

        display = self.set_mode((X, Y))

以下代码给出了此类型错误:

module() takes at most 2 arguments (3 given)

这是因为pygame.display是模块不是类吗?如何解决此错误?

编辑: 这是完整的追溯

Traceback (most recent call last):
  File "/Users/siyunlee/Desktop/coding/personal/games/dino game/main.py", line 4, in <module>
    class MainDisplay(display):
TypeError: module() takes at most 2 arguments (3 given)
import pygame.display.Display as display


class MainDisplay(display):

    def __init__(self):
        super.__init__()

        # creating display
        X = 500
        Y = 1000

        display = self.set_mode((X, Y))

The following code is giving this type error:

module() takes at most 2 arguments (3 given)

Is this because pygame.display is a module not a class? How could I fix this error?

edit:
this is the full traceback

Traceback (most recent call last):
  File "/Users/siyunlee/Desktop/coding/personal/games/dino game/main.py", line 4, in <module>
    class MainDisplay(display):
TypeError: module() takes at most 2 arguments (3 given)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

得不到的就毁灭 2025-02-04 12:12:02

这是一个简单的示例,说明如何制作一个窗口,我建议使用以下方式:

import pygame

class MainDisplay():

    def __init__(self):
        pygame.display.init()
        self.screen = pygame.display.set_mode((800, 600))

MainDisplay()
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

This is a simple example of how to make a window I recommend using this:

import pygame

class MainDisplay():

    def __init__(self):
        pygame.display.init()
        self.screen = pygame.display.set_mode((800, 600))

MainDisplay()
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文