[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Firing bullets



Well, I'm trying to get my program to fire bullets now. Isn't that great?

I think I'm doing it all wrong though...

My problem has been that I don't know how to make the program fire bullets. But then I thought, "shouldn't the character be firing the bullets, not the program?" and it's then that I realized why I couldn't do anything. My logic has been completely wrong. Again. Go figure <_<

Well, I still don't have images for characters yet and I still have no movement code (I should probably work on that, huh?) but everything else aside from the characters and bullets is done.

Once I finish these, I'll be able to probably try to work on a title screen and put a crappy proof-of-concept idea out there (which is pretty much all I need to finish my senior project - a proof-of-concept with a demo that is playable).

My question is: Is it possible to use bulletml to make bullet patterns for this game? I've seen a C++ wrapper for it called libbulletml but nothing much else.

So. I made a thread asking for help at the Game Programmer's Wiki Forums. Could you also look at that too?

I tried to fix his syntax (a class without an __init__ function? Don't you need those?) and this is what I have so far:


class Bullet:
    def __init__(self, position=(0,0), velocity=(0,0)):
        self.position = position
        self.velocity = velocity
        self.ttd = 5
    def fire(self):
        self.position = self.position
        self.velocity = self.velocity
    def update(self):
        position += velocity

class Big_Bullet(Bullet, pygame.sprite.Sprite):
    def __init__(self):
        Bullet.__init__(self)
        pygame.sprite.Sprite.__init__(self)
    def update(self):
        Bullet.update(self)

class Small_Bullet(Bullet):
    def __init__(self):
        Bullet.__init__(self)
    def update(self):
        Bullet.update(self)


Also, it's been kinda quiet lately, hasn't it?