设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 10590|回复: 0
打印 上一主题 下一主题

求助

[复制链接]

1

主题

0

好友

9

积分

新手上路

Rank: 1

跳转到指定楼层
楼主
发表于 2013-9-18 20:59:12 |只看该作者 |倒序浏览
想把打飞机那个游戏用sprite类写,但写不好
求教这个类改得对不对

class Bullet(pygame.sprite.Sprite):


    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.image.load('bullet.png').convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.center = (0, -1)
        self.active = False

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

    def restart(self):
        pos = pygame.mouse.get_pos()
        self.rect.center = pos
        self.active = True

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-13 01:16 , Processed in 0.024989 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部