这个怎么解决啊!!!
G:\python\python.exe G:/PyCharm/FlaPyBrid.pypygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Process finished with exit code 0
这个不是错误,是警告,一般不太影响 塔利班 发表于 2018-12-3 10:56
这个不是错误,是警告,一般不太影响
但是运行不了啊 LOVE_YuC 发表于 2018-12-3 11:06
但是运行不了啊
运行不了不是这个问题,你得贴代码,发截图 塔利班 发表于 2018-12-3 11:08
运行不了不是这个问题,你得贴代码,发截图
import pygame
from pygame.locals import *
import sys ,random
screen_width=400
screen_height=500
FPS=30
Image,Sound={},{}
Brid_List = (
(
'img/redbird-downflap.png',
'img/redbird-midflap.png',
'img/redbird-downflap.png',
),
(
'img/bluebird-upflap.png',
'img/bluebird-midflap.png',
'img/bluebird-downflap.png',
),
(
'img/yellowbird-upflap.png',
'img/yellowbird-midflap.png',
'img/yellowbird-downflap.png',
),
)
Background_List = (
'img/background-day.png',
'img/background-night.png',
)
# list of pipes
Pip_List = (
'img/pipe-green.png',
'img/pipe-red.png',
)
# 主循环 事件监听 关闭窗口
def main():
#全局变量
global surface, FpsClock
pygame.init()
FpsClock = pygame.time.Clock()
surface = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('Flappy Bird')
Image['number'] = (
pygame.image.load('img/0.png').convert_alpha(),
pygame.image.load('img/1.png').convert_alpha(),
pygame.image.load('img/2.png').convert_alpha(),
pygame.image.load('img/3.png').convert_alpha(),
pygame.image.load('img/4.png').convert_alpha(),
pygame.image.load('img/5.png').convert_alpha(),
pygame.image.load('img/6.png').convert_alpha(),
pygame.image.load('img/7.png').convert_alpha(),
pygame.image.load('img/8.png').convert_alpha(),
pygame.image.load('img/9.png').convert_alpha()
)
Image['gameover'] = pygame.image.load('img/gameover.png').convert_alpha()
Image['message'] = pygame.image.load('img/message.png').convert_alpha()
Image['base'] = pygame.image.load('img/base.png').convert_alpha()
if 'win' in sys.platform:
Suffix = '.wav'
else:
Suffix= '.ogg'
Sound['die'] = pygame.mixer.Sound('music/die'+Suffix)
Sound['hit'] = pygame.mixer.Sound('music/hit' + Suffix)
Sound['point'] = pygame.mixer.Sound('music/point' + Suffix)
Sound['swoosh'] = pygame.mixer.Sound('music/swoosh' + Suffix)
Sound['wing'] = pygame.mixer.Sound('music/wing' + Suffix)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# 投影实现
surface.blit(Image)
# 绘制图形
pygame.display.update()
# 设置帧率
FpsClock.tick(500)
if __name__ == '__main__':
main() surface.blit(Image)
image是个字典,你这能画出来个啥 塔利班 发表于 2018-12-3 11:19
surface.blit(Image)
image是个字典,你这能画出来个啥
谢谢您的提醒{:5_110:} 塔利班 发表于 2018-12-3 11:19
surface.blit(Image)
image是个字典,你这能画出来个啥
import pygame
from pygame.locals import *
import sys
import traceback
import myplane
pygame.init()
pygame.mixer.init()
bg_size = width, height = 480, 700
screen = pygame.display.set_mode(bg_size)
pygame.display.set_caption("飞机大战")
background = pygame.image.load("img/background.png").convert_alpha()
# 载入游戏音乐
pygame.mixer.music.load("music/game_music.ogg")
pygame.mixer.music.set_volume(0.2)
bullet_sound = pygame.mixer.Sound("music/bullet.wav")
bullet_sound.set_volume(0.2)
bomb_sound = pygame.mixer.Sound("music/use_bomb.wav")
bomb_sound.set_volume(0.2)
supply_sound = pygame.mixer.Sound("music/supply.wav")
supply_sound.set_volume(0.2)
get_bomb_sound = pygame.mixer.Sound("music/get_bomb.wav")
get_bomb_sound.set_volume(0.2)
get_bullet_sound = pygame.mixer.Sound("music/get_bullet.wav")
get_bullet_sound.set_volume(0.2)
upgrade_sound = pygame.mixer.Sound("music/upgrade.wav")
upgrade_sound.set_volume(0.2)
enemy3_fly_sound = pygame.mixer.Sound("music/enemy3_flying.wav")
enemy3_fly_sound.set_volume(0.2)
enemy1_down_sound = pygame.mixer.Sound("music/enemy1_down.wav")
enemy1_down_sound.set_volume(0.1)
enemy2_down_sound = pygame.mixer.Sound("music/enemy2_down.wav")
enemy2_down_sound.set_volume(0.2)
enemy3_down_sound = pygame.mixer.Sound("music/enemy3_down.wav")
enemy3_down_sound.set_volume(0.5)
me_down_sound = pygame.mixer.Sound("music/me_down.wav")
me_down_sound.set_volume(0.2)
def main():
pygame.mixer.music.play(-1)
# 生成我方飞机
me= myplane.MyPlane(bg_size)
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# 检测用户的键盘操作
key_pressed = pygame.key.get_pressed()
if key_pressed or key_pressed:
me.moveUp()
if key_pressed or key_pressed:
me.moveDown()
if key_pressed or key_pressed:
me.moveLeft()
if key_pressed or key_pressed:
me.moveRight()
screen.blit(background, (0, 0))
pygame.display.flip()
clock.tick(60)
if __name__ == '__main__':
try:
main()
except SystemExit:
pass
except:
traceback.print_exc()
pygame.quit()
input()
塔利班 发表于 2018-12-3 11:19
surface.blit(Image)
image是个字典,你这能画出来个啥
import pygame
class Myplane(pygame.sprite.Sprite):
def __init__(self, bg_size):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("img/me1.png").convert_alpha()
self.rect = self.image.get_rect()
self.width, self.height = bg_size, bg_size
self.rect.left, self.rect.top = (self.width - self.rect.width) // 2, \
self.height - self.rect.height - 60
self.speed=10
def moveUp(self):
if self.rect.top>0:
self.rect.top -=self.speed
else:
self.rect.top=0
def moveDown(self):
if self.rect.bottom < self.height:
self.rect.bottom += self.speed
else:
self.rect.bottom=self.height - 60
def moveLeft(self):
if self.rect.left > 0:
self.rect.left -= self.speed
else:
self.rect.left = 0
def moveRight(self):
if self.rect.right< self.width:
self.rect.right += self.speed
else:
self.rect.right = self.width
塔利班 发表于 2018-12-3 11:19
surface.blit(Image)
image是个字典,你这能画出来个啥
还是原来的libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile是你运行加载png的警告,但是不影响运行游戏,你运行游戏实现有什么问题才是你真正要关心的地方 塔利班 发表于 2018-12-3 15:03
libpng warning: iCCP: known incorrect sRGB profile是你运行加载png的警告,但是不影响运行游戏,你运行 ...
但是我的主角飞机没有显示啊 screen.blit(background, (0, 0))
你就blit一个背景
没有blit飞机,当然没有 塔利班 发表于 2018-12-3 15:15
screen.blit(background, (0, 0))
你就blit一个背景
没有blit飞机,当然没有
嗯嗯 , 已经解决了,谢谢 老师
页:
[1]