设为首页 收藏本站
开启辅助访问 快捷导航
菜单
猿人部落 主页 资讯 查看内容

关于飞机大战中子弹无法显示

2019-7-24 18:05 发布者: admin 评论 2 查看 1478
附上部分代码(根本上都是按小甲鱼来的):bullets.py------import pygameclass Bullet1(pygame.sprite.Sprite):    def __init__(self,position):        pygame.sprite.S
附上部分代码(根本上都是按小甲鱼来的):
bullets.py
------
import pygame

class Bullet1(pygame.sprite.Sprite):
    def __init__(self,position):
        pygame.sprite.Sprite.__init__(self)
        self.img = pygame.image.load('images/bullet1.png').convert_alpha()
        self.rect = self.img.get_rect()
        self.rect.left, self.rect.top = position
        self.speed = 12
        self.active = True
        self.mask = pygame.mask.from_surface(self.img)

    def move(self):
        self.rect.top = -self.speed
        if self.rect.top < 0:
            self.active = False


    def reset4(self,position):
        self.rect.left, self.rect.top = position
        self.active = True
------
main.py
------
...
    # Bullet
    bullet1=[]
    bullet1_num = 4
    bullet1_index = 0
    for each in range(bullet1_num):
        bullet1.append(bullets.Bullet1(me.rect.midtop))
...
while 1:
...
        if not (delay % 4):
            bullet1[bullet1_index].reset4(me.rect.midtop)
            bullet1_index = (bullet1_index + 1) % bullet1_num

        for b in bullet1:
            if b.active:
                b.move()
                screen.blit(b.img,b.rect)
                enemy_hit = pygame.sprite.spritecollide(b,total_enemy,False,pygame.sprite.collide_mask)
                if enemy_hit:
                    b.active = False
                    for e in enemy_hit:
                        e.destory = True

...
------

能跑起来就是没子弹,看了一下战书。。求大神辅导,会有libpng warning: iCCP: known incorrect sRGB profile,但网上看说没什么关系

路过

雷人

握手

鲜花

鸡蛋
收藏 邀请
上一篇:[已解决]下一篇:美腿控福利---python爬虫某著名美女美腿网站

相关阅读

一周热门

头条攻略!

日排行榜

相关分类