如下图,程序是能正常运行的,运行中不会报错,但是程序代码上总会有红色的波浪下划线,
虽然我知道右下角有个工具可以调节以不显示这些红色的波浪下划线,但我想知道原因,
想知道为什么会出现这些红色的波浪下划线。求大神们告知~~~
附上代码:
#导入模块和常量import pygame,sys,random,timefrom pygame.locals import *
#初始化pygame.init()
#绘制屏幕窗口
screen = pygame.display.set_mode((600,600))
pygame.display.set_caption("pygame作业ver-2.4")
color = 255,255,255
pos_x = 300
pos_y = 300
vel_x = 2
vel_y = 1
while True:
for event in pygame.event.get():
if event.type in (QUIT,KEYDOWN):
sys.exit()
screen.fill((255,255,255))
pos_x += vel_x
pos_y += vel_y
if pos_x >= 500 or pos_x <= 0:
vel_x = -vel_x
color = random.randint(0,255),random.randint(0,255),random.randint(0,255)
if pos_y >= 500 or pos_y <= 0:
vel_y = -vel_y
color = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)
pygame.draw.rect(screen,color,(pos_x,pos_y,100,100),0)
time.sleep(0.01)
pygame.display.flip()
虽然我知道右下角有个工具可以调节以不显示这些红色的波浪下划线,但我想知道原因,
想知道为什么会出现这些红色的波浪下划线。求大神们告知~~~
附上代码:
#导入模块和常量import pygame,sys,random,timefrom pygame.locals import *
#初始化pygame.init()
#绘制屏幕窗口
screen = pygame.display.set_mode((600,600))
pygame.display.set_caption("pygame作业ver-2.4")
color = 255,255,255
pos_x = 300
pos_y = 300
vel_x = 2
vel_y = 1
while True:
for event in pygame.event.get():
if event.type in (QUIT,KEYDOWN):
sys.exit()
screen.fill((255,255,255))
pos_x += vel_x
pos_y += vel_y
if pos_x >= 500 or pos_x <= 0:
vel_x = -vel_x
color = random.randint(0,255),random.randint(0,255),random.randint(0,255)
if pos_y >= 500 or pos_y <= 0:
vel_y = -vel_y
color = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)
pygame.draw.rect(screen,color,(pos_x,pos_y,100,100),0)
time.sleep(0.01)
pygame.display.flip()