鱼C论坛

 找回密码
 立即注册
查看: 1289|回复: 3

[已解决]为啥背景颜色一直是黑色啊,改颜色也没用?

[复制链接]
发表于 2022-3-16 10:12:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 是啊柴啊 于 2022-3-16 10:16 编辑

import pygame
import sys
pygame.init()
size=width,height=600,400
speed=[-2,1]
bg=(230,255,255)
screen=pygame.display.set_mode(size)
pygame.display.set_caption("大战外星人!")
turtle=pygame.image.load("turtle.png")
position=turtle.get_rect()
while True:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            sys.exit()
position=position.move(speed)
if position.left<0 or position.right>width:
    turtle=pygame.transform.flip(turtle,True,False)
    speed[0]=-speed[0]
if position.top<0 or position.bottom>height:
    speed[1]=-speed[1]
screen.fill(bg)
screen.blit(turtle,position)
pygame.display.flip()
pygame.time.delay(10)
最佳答案
2022-3-16 10:30:44
缩进
  1. while True:
  2.         for event in pygame.event.get():
  3.                 if event.type==pygame.QUIT:
  4.                             sys.exit()
  5.         position=position.move(speed)
  6.         if position.left<0 or position.right>width:
  7.                 turtle=pygame.transform.flip(turtle,True,False)
  8.                 speed[0]=-speed[0]
  9.         if position.top<0 or position.bottom>height:
  10.                 speed[1]=-speed[1]
  11.         screen.fill(bg)
  12.         screen.blit(turtle,position)
  13.         pygame.display.flip()
  14.         pygame.time.delay(10)
复制代码

$9EN~R%(D%3Y)T(SB9SJC`8.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-3-16 10:30:44 | 显示全部楼层    本楼为最佳答案   
缩进
  1. while True:
  2.         for event in pygame.event.get():
  3.                 if event.type==pygame.QUIT:
  4.                             sys.exit()
  5.         position=position.move(speed)
  6.         if position.left<0 or position.right>width:
  7.                 turtle=pygame.transform.flip(turtle,True,False)
  8.                 speed[0]=-speed[0]
  9.         if position.top<0 or position.bottom>height:
  10.                 speed[1]=-speed[1]
  11.         screen.fill(bg)
  12.         screen.blit(turtle,position)
  13.         pygame.display.flip()
  14.         pygame.time.delay(10)
复制代码

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-3-16 19:20:01 | 显示全部楼层
谢谢!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-3-16 19:20:45 | 显示全部楼层

谢谢老哥!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-8 09:05

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表