【问题标题】:Pygame module (I can't import the rect class)Pygame 模块(我无法导入 rect 类)
【发布时间】:2020-07-25 15:45:06
【问题描述】:
import #pygame
from PYGAME.locals import *
from RECT import *

pygame.init()

#Make Screen
screen = pygame.display.set_mode((640,240))

#Defining the colors
BLACK = (0,0,0)
GRAY = (127,127,127)
WHITE = (255,255,255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
CYAN = (0, 255, 255)
MAGENTA = (255, 0, 255)

#Defining a function
def draw_point(text,pos):
    img = font.render(text,True,BLACK)
    pygame.draw.circle(screen,RED,pos,3)
    screen.blit(img,pos)

我无法在第三行导入RECT 类。这是我第一次在网上发布疑问,感谢您的帮助。因此,我无法定义draw_point 函数。

【问题讨论】:

  • import #pygame -> import pygamefrom RECT import * -> from pygame import Rect

标签: python python-3.x pygame pygame-surface


【解决方案1】:

您的代码没有使用RECT,所以我只能猜测您要导入的内容。

import pygame
from pygame.locals import *
from pygame import rect, Rect #one of these is probably what you want

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多